macOS 10.13 and iOS 11 Release Notes

Cocoa Foundation Framework

Key Path and KVO Improvements in Swift

Archiving in Swift

NSDistributedNotificationCenter

NSMapTable

NSNumber

let n = NSNumber(value: UInt32(543))

let v = n as? UInt32

// v is UInt32(543)

let v: UInt32 = 543

let n = v as NSNumber

// n == NSNumber(value: 543)

let n = NSNumber(value: UInt32(543))

let v = n as? Int16

// v is Int16(543)

// Failures when casting that losses the value stored

let n = NSNumber(value: UInt32(543))

let v = n as? Int8

// v is nil

NSOperation

NSOperationQueue

NSTask

NSThread

NSRange

let ranges = Set<NSRange>([NSRange(location: 4, length: 10), NSRange(location: 2, length: 3)])

print(ranges) // prints [{4, 10}, {2, 3}]

NSXPCConnection support for discrete NSProgress

@protocol ServerProtocol

// This is a traditional callback

- (void)remoteCallWithReply:(void (^)(BOOL success))reply;

// This is the newly allowed style

- (NSProgress *)remoteCallWithProgressAndReply:(void (^)(BOOL success))reply;

@end

@protocol ProgressReportingService <NSObject>

- (NSProgress *)performRequestWithReply:(void (^)(BOOL success))reply;

@end

- (NSProgress *)performRequestWithReply:(void (^)(BOOL))reply {

NSProgress * progress = [NSProgress progressWithTotalUnitCount:30];

dispatch_async(dispatch_get_global_queue(0, 0), ^{

progress.completedUnitCount = 10;

usleep(100000);

progress.completedUnitCount = 20;

usleep(100000);

progress.completedUnitCount = 30;

usleep(100000);

reply(YES);

});

return progress;

}

- (void)callRequest {

NSProgress *localProgress = [[NSProgress alloc] init];

localProgress.totalUnitCount = 1;

id proxy = [_connection remoteObjectProxy];

NSProgress *remoteProgress = [proxy performRequestWithReply:^(BOOL success) {

/* Operation is finished here */

}];

[localProgress addChild:remoteProgress withPendingUnitCount:1];

// At this point, localProgress will update as remoteProgress is updated. You may observe it as usual.

}

NSLinguisticTagger

NSOrthography

NSRegularExpression/NSTextCheckingResult

NSURL

NSURLVolumeSupportsImmutableFilesKey

NSURLVolumeSupportsAccessPermissionsKey

NSURLVolumeAvailableCapacityForImportantUsageKey

NSURLVolumeAvailableCapacityForOpportunisticUsageKey

NSURLComponents

NSURLSession Adaptable Connectivity API

NSURLSession ProgressReporting

NSURLSession brotli support

NSURLSessionTask Scheduling API

NSURLSessionStreamTask proxy support

Collection Copy-on-Write

Collection conveniences

- (BOOL)writeToURL:(NSURL *)url error:(NSError **)error;

- (nullable NSArray<ObjectType> *)initWithContentsOfURL:(NSURL *)url error:(NSError **)error;

+ (nullable NSArray<ObjectType> *)arrayWithContentsOfURL:(NSURL *)url error:(NSError **)error;

- (BOOL)writeToURL:(NSURL *)url error:(NSError **)error;

- (nullable NSDictionary<NSString *, ObjectType> *)initWithContentsOfURL:(NSURL *)url error:(NSError **)error;

+ (nullable NSDictionary<NSString *, ObjectType> *)dictionaryWithContentsOfURL:(NSURL *)url error:(NSError **)error;

Collection getObjects: APIs

NSJSONSerialization

plutil

Relaxed Key-Value Observing Unregistration Requirements

NSUserDefaults KVO improvements (New since Seed 1)

NSUserDefaults Data Loss Fix

NSFileHandle readabilityHandler Behavior Change

NSPropertyListSerialization Old-Style Property List Memory Use Reduction (New since Seed 1)

Swift KeyPath Adoption in Foundation APIs

Improved NSUserDefaults Handling of Invalid Files

Improved Handling of Mis-nested Key-Value Observing Calls

CFLocaleCopyCurrent() Concurrency Improvements

UserDefaults nil Handling Fix

NSXMLParser Invalid Data Handling Improvement

NSXMLDocument xmlns + NSXMLNodePreservePrefixes Fix

NSError