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!
Like NSNumber, NSString is also immutable type. It's used to represent text in Objective-C. NSString provides built-in support for Unicode, which means that we can include UTF-8 characters directly in string literals.
A static, plain-text Unicode string object that bridges to String ; use NSString when you need reference semantics or other Foundation-specific behavior.
Simple to transfer
const char *cfilename=[stringobject UTF8String];
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