When reading the headers of Foundation I found this:
- (__strong const char *)UTF8String NS_RETURNS_INNER_POINTER;
// Convenience to return null-terminated UTF8 representation
This is from NSString.h
in the iOS 7.1 SDK, what does __strong const char *
mean here?
I'm most confused about the "__strong"
here.
const char* is a mutable pointer to an immutable character/string. You cannot change the contents of the location(s) this pointer points to. Also, compilers are required to give error messages when you try to do so. For the same reason, conversion from const char * to char* is deprecated.
In general, you can pass a char * into something that expects a const char * without an explicit cast because that's a safe thing to do (give something modifiable to something that doesn't intend to modify it), but you can't pass a const char * into something expecting a char * (without an explicit cast) because that's ...
Foundation is shared between iOS and Mac OS. On Mac OS, for a while there existed a garbage collection memory management system. It's now deprecated and not longer supported on Mac OS. It was never used on iOS.
GC used __strong
as a modifier on plain pointer type declarations to make the pointed to memory collectible. This usage of __strong
has no meaning in ARC or manual retain/release code. The fact that there's no warning for the declaration is probably only because clang issues no warnings in system headers.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With