Java conversion to Objective-C

1

I need to convert this little Java code to Objective-C to execute a function in Objective-C, but it has an error that I still can not figure out.

Java code:

final char CHR0 = 0;
String finalprotocolo = "" + CHR0 + "";

String ligartv = "/ARP/IR/enviar/LigaTV" + finalprotocolo;
byte[] arrayligartv = ligartv.getBytes();

Objective-C code:

    unichar c = 0x00;// c = 0x00;
    NSString *nova = [NSString stringWithFormat:@"%c", c];
    //NSString *nova = [NSString stringWithCharacters:&c length:1];
    // Pega a menssagem<br>
    NSString *final = @"/ARP/enviar/LigaTV";
    NSString *mensagem = [final stringByAppendingString:nova];

I need to perform the same function as the Java code, just transforming byte 0 into String and adding the Objective-C message variable.

    
asked by anonymous 29.10.2014 / 11:48

1 answer

1
  

I need to perform the same function as the Java code, just transforming byte 0 into String and adding the Objective-C message variable.

An example of transforming a unichar into NSString would be like the code below:

- (void)viewDidLoad {
     [super viewDidLoad];
     // Do any additional setup after loading the view, typically from a nib.
     unichar unicharA = 0x0391;
     NSLog(@"converterUnichar = %@", [self converterUnichar:unicharA])
}
-(NSString*) converterUnichar:(unichar) c{
     NSString *stringRetorno = [NSString stringWithCharacters:&c length:1];
     return stringRetorno;
}

Would that be just that? Hope to have helped, hug

    
29.10.2014 / 20:40