Monday, May 20, 2013

NSString UTF8String example ios


[NSString UTF8String]

Returns a null-terminated UTF8 representation of the receiver.
- (const char *)UTF8String
Return Value
A null-terminated UTF8 representation of the receiver.
Discussion of [NSString UTF8String]
The returned C string is automatically freed just as a returned object would be released; you should copy the C string if it needs to store it outside of the autorelease context in which the C string is created.
Example of [NSString UTF8String]
char *utf8string = [@"A string with ümläuts" UTF8String];
Example of [NSString UTF8String]
NSString *s = @"Some string";
  const char *c = [s UTF8String];
Example of [NSString UTF8String]
const char* utf8Str = [@"an example string" UTF8String];
if (utf8Str != NULL) 
{
    stringIWantToKeep = strdup(utf8Str);
}