__strong
means that the object (of class NSString in this case), that holds the pointer, retains its ownership till the end of the life of the object and the pointed memory will be garbage-collected. Hence INNER
.
const char *
means that the char
array this pointer points to is constant, i.e. cannot be changed for example by changing some characters in it (you will get a compiler error).
If you try to compile this:
#import <Foundation/Foundation.h>
int main(int argc, char **argv)
{
NSString *s = @"string";
const char *str = [s UTF8String];
printf("%s\n", str);
str[0] = 'S';
printf("%s\n", str);
return 0;
}
you'll get read-only variable is not assignable
error.
-(__strong const char *)foo NS_RETURNS_INNER_POINTER;
then the compiler warns that "'__strong' only applies to Objective-C object or block pointer types; type here is 'const char *'".UTF8String
declaration is probably only due to the fact that clang (and other compilers) suppress warnings in system headers.