I have been able to find methods like -[NSString stringWithCString:encoding:] but they do not seem to play well when the cstring is a pointer.
I have been able to find methods like -[NSString stringWithCString:encoding:] but they do not
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
First up, don’t use
initWithCString, it has been deprecated.Couple of ways you can do this:
If you need another encoding like ASCII:
If you want to see all the string encodings available, in Xcode, hold command + option then double click on
NSASCIIStringEncodingin the above code block.You will be able to see where Apple have declared their enumeration for the string encoding types. Bit quicker than trying to find it in the documentation.
Some other ones you might need:
Checkout Apple’s NSString Class Reference (encodings are at the bottom of the page)