Next question in my migration. How do I do what this did in Swift 2.2?

let theData = String.init(bytes: data.memory, length: length, encoding: NSUTF8StringEncoding)

The only initialisers that have a length are

init?(bytesNoCopy: UnsafeMutableRawPointer, length: Int, encoding: String.Encoding, freeWhenDone: Bool) init(utf16CodeUnitsNoCopy: UnsafePointer<unichar>, count: Int, freeWhenDone: Bool)

Neither is applicable.

Do I need to push it into a Data object first, like this?

let theData = String.init(data: Data.init(bytes: data, length: length), encoding: String.Encoding.utf8)

Or is there a better way that I've missed (highly possible)?

John
--
John Brownie
In Finland on furlough from SIL Papua New Guinea
_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users

Reply via email to