Returns a representation of the receiver as a C string using a given encoding.
- iOS 2.0+
- macOS 10.4+
- tvOS 9.0+
- watchOS 2.0+
The encoding for the returned C string. For possible values, see
A C string representation of the receiver using the encoding specified by
NULL if the receiver cannot be losslessly converted to
The returned C string is guaranteed to be valid only until either the receiver is freed, or until the current memory is emptied, whichever occurs first. You should copy the C string or use
get if it needs to store the C string beyond this time.
You can use
can to check whether a string can be losslessly converted to
encoding. If it can’t, you can use
data(using: to get a C-string representation using
encoding, allowing some loss of information (note that the data returned by
data(using: is not a strict C-string since it does not have a