How to convert unsigned char to NSString in iOS

Viewed 18933

Can anyone tell me how to convert an unsigned char to an NSString?

Here's the code I am using, but for some reason if I try to do anything with the NSString, like set a UITextView text, it gives me an error. The NSLog works correctly though. Thanks in advance.

- (void)onTagReceived:(unsigned char *)tag
{

NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSString *myTag = [NSString stringWithFormat:@"%02x%02x%02x%02x%02x\n",tag[0],tag[1],tag[2],tag[3],tag[4]];

NSLog(@"currentTag: %@",myTag);

[displayTxt setText:myTag];

[pool release];

}
2 Answers
Related