init(data:encoding:)
Returns an NSString object initialized by converting given data into UTF-16 code units using a given encoding.
Declaration
convenience init?(data: Data, encoding: UInt)Parameters
- data:
An
NSDataobject containing bytes inencodingand the default plain text format (that is, pure content with no attributes or other markups) for that encoding. - encoding:
The encoding used by
data. For possible values, see Nsstringencoding.
Return Value
An NSString object initialized by converting the bytes in data into UTF-16 code units using encoding. The returned object may be different from the original receiver. Returns nil if the initialization fails for some reason (for example if data does not represent valid data for encoding).
See Also
Creating and Initializing Strings
init()init(bytes:length:encoding:)init(bytesNoCopy:length:encoding:freeWhenDone:)init(characters:length:)init(charactersNoCopy:length:freeWhenDone:)init(string:)init(format:arguments:)init(format:locale:arguments:)localizedUserNotificationString(forKey:arguments:)localizedStringWithFormat(_:_:)unichar