Initializes the receiver, a newly allocated
NSString object, by converting the data in a given C-string from the default C-string encoding into the Unicode character encoding.
- iOS 2.0–2.0Deprecated
- macOS 10.0–10.4Deprecated
- Mac Catalyst 13.0–13.0Deprecated
- tvOS 9.0–9.0Deprecated
- watchOS 2.0–2.0Deprecated
This method converts
sizeof(char) bytes from
c and doesn’t stop short at a zero character.
c must contain data in the default C-string encoding and may not be
NULL. The receiver becomes the owner of
true it will free the memory when it no longer needs it, but if
false it won’t. Returns an initialized object, which might be different from the original receiver.
You can use this method to create an immutable string from an immutable (
const char *) C-string buffer. If you receive a warning message, you can disregard it; its purpose is simply to warn you that the C string passed as the method’s first argument may be modified. If you make certain the
free argument to
false, the C string passed as the method’s first argument cannot be modified, so you can safely use
init to create an immutable string from an immutable (
const char *) C-string buffer.