I have one query related conversion I have one NSString object with content some string like below
NSString *string = @"do nothing";
Now I am trying to pass string in below code like
const char inputString[] = string;
Xcode showing error
Array initializer must be an initializer list or string literal.
Is there any workaround for the same.
Thanks in advance,
The simpliest is to use UTF-8 conversion (which replaces the old and long deprecated - (const char *)cString method):
const char *Cstr = myObjCStr.UTF8String;
Try this
NSString *string = @"do nothing";
const char * inputString = [string UTF8String];
If you want to use other encoding,use this cStringUsingEncoding
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With