Converting an NSString* to char?

2020-05-17 02:00发布

问题:

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!

回答1:

Simple to transfer

const char *cfilename=[stringobject UTF8String];