How to convert an NSString to Char and vice versa

I have a lot of code written in C, since I'm writing code for the iPhone the need of reusing this old code has arisen.

One of the first thing to do is the conversion between NSString and char *

you can convert NSString to char* simply using the following line of code:

const char *myString = [myNSString UTF8String];

and viceversa

NSString *myNSString  = [NSString stringWithUTF8String:myString];




If you found useful this article, please share it using the social buttons below. Thank you in advance,


You may also like...

1 Response

Leave a Reply

Your email address will not be published. Required fields are marked *