June 20th, 2012, 06: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, 01:34 AM
NSString * aString = @"This is a string";
char const * charArray = [aString UTF8String];
September 4th, 2012, 03: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, 08: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