ingh.am
ingh.am

Reputation: 26812

Converting an NSString* to char?

How can I convert a NSString* into a char?

EDIT: Thanks to Vladimir for getting me there!

NSString *myString = @"HelloWorld";
const char *stringAsChar = [myString cStringUsingEncoding:[NSString defaultCStringEncoding]];

Hope this helps someone in the future!

Upvotes: 35

Views: 45417

Answers (1)

GameLoading
GameLoading

Reputation: 6708

Simple to transfer

const char *cfilename=[stringobject UTF8String];

Upvotes: 68

Related Questions