June 20th, 2012, 07:03 AM
Convert NSString to char array
I have a very long String but want to convert it to a char array, something like unsigned char. for example:
NSString *str = "Thisisaverylongstringofstringsjoinedtogether";
unsigned char c = str;
I hope someone understands what i want and help me out. Thanks
July 18th, 2012, 02:34 AM
NSString * aString = @"This is a string";
char const * charArray = [aString UTF8String];
September 4th, 2012, 04:13 AM
Emma has given the right answer.
If your string is encoded with something other than UTF-8, you could also use -[NSString cStringUsingEncoding:]
December 28th, 2012, 09:01 AM
The solutions is following.
Yes, We can convert the NSString to NSArray.
There is predefined function for doing this operation.
Following will help:
- (NSArray *)componentsSeparatedByStringNSString *)separator
- (NSString *)componentsJoinedByStringNSString *)separator