Reputation: 25099
Lets say i have the following cstring
char array[1000];
How i can convert it to NSString and vice verse.
Thanks.
Upvotes: 3
Views: 4289
Reputation: 38586
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.
Upvotes: 11