WWDC 19
Advances in Foundation
Ordered collection diffing:
let diff = bird.difference(from: bear) bear.applying(diff)
Data’s storage is now always a contiguous area in memory
ContiguousBytes: withUnsafeBytes(_ body: (UnsafeRawBufferPointer) -> R)
DataProtocol, MutableDataProtocol
Compression:
let compressed = try data.compressed(using: CompressionAlgorithm.lzfse / .lz4 / .lzma / .zlib)
UnitDuration: + milliseconds, microseconds, nanoseconds, picoseconds
UnitFrequency: + framesPerSecond
UnitInformationStorage (bits, bytes, kilo, etc.)
RelativeDateTimeFormatter: for formatting dates as e.g. "2 weeks ago"
ListFormatter: for formatting lists of things in a language-specific way
NSOperationQueue: addBarrierBlock { save() }
queue.progress.totalUnitCount – set this and then show 2/10 etc.
scanner.scanUpToCharacters(from: …) returns a String directly instead of through a reference
Support for USB drives and network volumes
Use FileManager.SearchPathDirectory.itemReplacementDirectory when writing files to USB / SMB
Do filesystem access on a background thread, because it might be loading from the network!
Test filesystem capabilities with URLResourceKey
Be prepared to handle errors