I want to get the characters of an NSString. Like this:
NSString *data;
const char * typein = [[data characters] UTF8String];
But obviously NSString won't respond to -characters. How do I get the characters of NSString?
thanks, Elijah
I want to get the characters of an NSString. Like this:
NSString *data;
const char * typein = [[data characters] UTF8String];
But obviously NSString won't respond to -characters. How do I get the characters of NSString?
thanks, Elijah
You can use this function:
for(int i =0 ;i<[myString length]; i++) {
char = [myString characterAtIndex:i];
}
or
NSString *str = @"astring";
const char *cString = [str UTF8String];
If you just want to get a cString from the NSString just call UTF8String
as you are already doing and then iterate the array.