Initializer

init(contentsOf:)

Initializes the receiver, a newly allocated NSString object, by reading data from the location named by a given URL.

Declaration

convenience init?(contentsOf url: URL)

Discussion

Initializes the receiver, a newly allocated NSString object, by reading data from the location named by aURL. If the contents begin with a byte-order mark (U+FEFF or U+FFFE), interprets the contents as UTF-16 code units; otherwise interprets the contents as data in the default C string encoding. Returns an initialized object, which might be different from the original receiver, or nil if the location can’t be opened.

See Also

Related Symbols

init(contentsOf: URL, encoding: UInt)

Returns an NSString object initialized by reading data from a given URL interpreted using a given encoding.

init(contentsOf: URL, usedEncoding: UnsafeMutablePointer<UInt>?)

Returns an NSString object initialized by reading data from a given URL and returns by reference the encoding used to interpret the data.