tags:

views:

74

answers:

1

Lets say i have the following cstring

char array[1000];

How i can convert it to NSString and vice verse.

Thanks.

+6  A: 

Apple's Developer Reference has a good article on this subject. Basically, you will do something like this:

NSString *stringFromUTFString = [[NSString alloc] initWithUTF8String:utf8String];

if the string is UTF8 encoded. Otherwise, you can use initWithCString:encoding: with which you can specify the encoding.

Here is a list of available string encodings.

Jorge Israel Peña