Initializer

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 NSData object containing bytes in encoding and 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).