<!--
{
  "documentType" : "article",
  "framework" : "macOS Release Notes",
  "identifier" : "/documentation/macOS-Release-Notes/foundation-release-notes",
  "metadataVersion" : "0.1.0",
  "role" : "article",
  "title" : "Foundation Release Notes"
}
-->

# Foundation Release Notes

Update your apps to use new features, and test your apps against API changes.

## Discussion

Foundation in macOS 10.14, iOS 12, watchOS 5, and tvOS 12 includes new features, API changes, and deprecations. For information about earlier releases, see [Foundation Release Notes for macOS 10.13 and iOS 11](https://developer.apple.com/library/archive/releasenotes/Foundation/RN-Foundation/index.html).

### Secure Data Archival and Unarchival

The <doc://com.apple.documentation/documentation/Foundation/NSKeyedArchiver> and <doc://com.apple.documentation/documentation/Foundation/NSKeyedUnarchiver> classes have new initializers and helper methods that make it easier for you to enable secure coding for archival and unarchival. Each initializer or helper method replaces a corresponding member that’s now deprecated.

- <doc://com.apple.documentation/documentation/Foundation/NSKeyedArchiver/init(requiringSecureCoding:)> replaces <doc://com.apple.documentation/documentation/Foundation/NSKeyedUnarchiver/init()> and <doc://com.apple.documentation/documentation/Foundation/NSKeyedArchiver/init(forWritingWith:)>.
- <doc://com.apple.documentation/documentation/Foundation/NSKeyedArchiver/archivedData(withRootObject:requiringSecureCoding:)> replaces <doc://com.apple.documentation/documentation/Foundation/NSKeyedArchiver/archivedData(withRootObject:)> and <doc://com.apple.documentation/documentation/Foundation/NSKeyedArchiver/archiveRootObject(_:toFile:)>.
- <doc://com.apple.documentation/documentation/Foundation/NSKeyedUnarchiver/init(forReadingFrom:)> replaces <doc://com.apple.documentation/documentation/Foundation/NSKeyedUnarchiver/init()> and <doc://com.apple.documentation/documentation/Foundation/NSKeyedUnarchiver/init(forReadingWith:)>.
- <doc://com.apple.documentation/documentation/Foundation/NSKeyedUnarchiver/unarchivedObject(ofClass:from:)> and <doc://com.apple.documentation/documentation/Foundation/NSKeyedUnarchiver/unarchivedObject(ofClasses:from:)-b9t5> replace <doc://com.apple.documentation/documentation/Foundation/NSKeyedUnarchiver/unarchiveObject(with:)>, <doc://com.apple.documentation/documentation/Foundation/NSKeyedUnarchiver/unarchiveTopLevelObjectWithData(_:)>, and <doc://com.apple.documentation/documentation/Foundation/NSKeyedUnarchiver/unarchiveObject(withFile:)>.

You use the new <doc://com.apple.documentation/documentation/Foundation/NSKeyedUnarchiver/unarchivedObject(ofClasses:from:)-b9t5> method when unarchiving instances that are subclasses of one of the list of classes you supply. You can use these initializers and helper methods in apps that are compatible with macOS 10.13, iOS 11, watchOS 4, tvOS 11, and subsequent releases of each operating system.

For more information, see the WWDC 2018 session [Data You Can Trust](https://developer.apple.com/videos/play/wwdc2018/222/).

### Secure Value Transformer

<doc://com.apple.documentation/documentation/Foundation/NSSecureUnarchiveFromDataTransformer> is a new subclass of <doc://com.apple.documentation/documentation/Foundation/ValueTransformer>. It uses <doc://com.apple.documentation/documentation/Foundation/NSKeyedArchiver> and <doc://com.apple.documentation/documentation/Foundation/NSKeyedUnarchiver> to archive and unarchive data by enabling `requiresSecureCoding`.

When unarchiving from <doc://com.apple.documentation/documentation/Foundation/NSData>, <doc://com.apple.documentation/documentation/Foundation/NSSecureUnarchiveFromDataTransformer> uses its <doc://com.apple.documentation/documentation/Foundation/NSSecureUnarchiveFromDataTransformer/allowedTopLevelClasses> list to decode objects by calling the new <doc://com.apple.documentation/documentation/Foundation/NSKeyedUnarchiver/unarchivedObject(ofClasses:from:)-b9t5> method. By default, this list includes all property list types—<doc://com.apple.documentation/documentation/Foundation/NSArray>, <doc://com.apple.documentation/documentation/Foundation/NSDictionary>, <doc://com.apple.documentation/documentation/Foundation/NSString>, <doc://com.apple.documentation/documentation/Foundation/NSNumber>, <doc://com.apple.documentation/documentation/Foundation/NSDate>, <doc://com.apple.documentation/documentation/Foundation/NSData>, and <doc://com.apple.documentation/documentation/Foundation/NSNull>—along with <doc://com.apple.documentation/documentation/Foundation/NSURL> and <doc://com.apple.documentation/documentation/Foundation/NSUUID>.

When archiving to <doc://com.apple.documentation/documentation/Foundation/NSData>, this transformer calls the new <doc://com.apple.documentation/documentation/Foundation/NSKeyedArchiver/archivedData(withRootObject:requiringSecureCoding:)> method and enables requiresSecureCoding.

To transform top-level values of types other than the defaults listed above, subclass <doc://com.apple.documentation/documentation/Foundation/NSSecureUnarchiveFromDataTransformer>.

- If you expect to decode a top-level value of only one allowed type, override <doc://com.apple.documentation/documentation/Foundation/ValueTransformer/transformedValueClass()> to return that type. Doing so populates <doc://com.apple.documentation/documentation/Foundation/NSSecureUnarchiveFromDataTransformer/allowedTopLevelClasses> automatically.
- If you expect to decode a top-level value of one of several allowed types, override <doc://com.apple.documentation/documentation/Foundation/NSSecureUnarchiveFromDataTransformer/allowedTopLevelClasses> to return those types.

The older <doc://com.apple.documentation/documentation/Foundation/NSValueTransformerName/unarchiveFromDataTransformerName> and <doc://com.apple.documentation/documentation/Foundation/NSValueTransformerName/keyedUnarchiveFromDataTransformerName> values are now deprecated.

### NSSecureCoding Conformance

The <doc://com.apple.documentation/documentation/Foundation/NSPointerFunctions>, <doc://com.apple.documentation/documentation/Foundation/NSMapTable>, and <doc://com.apple.documentation/documentation/Foundation/NSHashTable> classes now support limited conformance to the <doc://com.apple.documentation/documentation/Foundation/NSSecureCoding> protocol.
You can securely encode pointer-function consuming collections as long as you configure them with the following personalities and kinds of memory:

- <doc://com.apple.documentation/documentation/Foundation/NSPointerFunctions/Options/objectPersonality>
- <doc://com.apple.documentation/documentation/Foundation/NSPointerFunctions/Options/objectPointerPersonality>
- <doc://com.apple.documentation/documentation/Foundation/NSPointerFunctions/Options/strongMemory>
- <doc://com.apple.documentation/documentation/Foundation/NSPointerFunctions/Options/weakMemory>
- <doc://com.apple.documentation/documentation/Foundation/NSPointerFunctions/Options/copyIn> (optional)

> Important: Weak values won’t round-trip as expected unless you strongly reference them elsewhere during unarchival.

### Macro for Closed Enumerations

`NS_CLOSED_ENUM` is a new macro for declaring enumerations. You use it only for enumerations that are guaranteed to never gain an additional case. Usually you determine that there won’t be new cases because the enumeration you’re modeling represents a mathematically complete set. <doc://com.apple.documentation/documentation/Foundation/ComparisonResult> now adopts the `NS_CLOSED_ENUM` macro. It won’t ever gain additional cases.

> Important: Once an enumeration is marked as closed, it’s a binary- and source-incompatible change to add a new value. If you have any doubt about an enumeration gaining a private or additional public case in the future, use the `NS_ENUM` macro instead.

For information about `NS_CLOSED_ENUM` and choosing between it and other macros for grouping constants, see <doc://com.apple.documentation/documentation/Swift/grouping-related-objective-c-constants>.

### UserDefaults

<doc://com.apple.documentation/documentation/Foundation/UserDefaults> has several bug fixes and improvements:

- Removed synchronization requirements. It’s no longer necessary to use <doc://com.apple.documentation/documentation/Foundation/UserDefaults/synchronize()>, <doc://com.apple.documentation/documentation/CoreFoundation/CFPreferencesAppSynchronize(_:)>, or <doc://com.apple.documentation/documentation/CoreFoundation/CFPreferencesSynchronize(_:_:_:)>. These methods will be deprecated in a future version of the OS.Now that you don’t need to call these synchronization methods, the performance characteristics of <doc://com.apple.documentation/documentation/Foundation/UserDefaults> and Preferences Utilities are slightly different: The time taken for enqueueing write operations is now paid by the writing thread, rather than by the next thread to call <doc://com.apple.documentation/documentation/Foundation/UserDefaults/synchronize()> or do a read operation.
- Removed retains when adding an observer. Adding observers to an instance of <doc://com.apple.documentation/documentation/Foundation/UserDefaults> using the <doc://com.apple.documentation/documentation/ObjectiveC/NSObject-swift.class/addObserver(_:forKeyPath:options:context:)> method unintentionally retained it, unlike all other uses of key-value observing. This has been corrected, and normal Cocoa memory management rules are now followed.
- Fixed key-value observing bug in <doc://com.apple.documentation/documentation/Foundation/UserDefaults>. Reading defaults on one thread while another thread set defaults could nondeterministically send key-value observing notifications on both threads, rather than just the thread doing the set operation. This is now fixed.

### On-Demand Resources

<doc://com.apple.documentation/documentation/Foundation/NSBundleResourceRequest> no longer throws exceptions when encountering certain kinds of internal errors. Instead, it returns an error in the error argument of the completion handler of the <doc://com.apple.documentation/documentation/Foundation/NSBundleResourceRequest/beginAccessingResources(completionHandler:)> method. The error might include the <doc://com.apple.documentation/documentation/Foundation/NSFileReadUnknownError-swift.var> and `NSXPCConnectionInterrupted` errors in addition to <doc://com.apple.documentation/documentation/Foundation/NSUserCancelledError-swift.var> and network-related errors.

If your app encounters an error when using <doc://com.apple.documentation/documentation/Foundation/NSBundleResourceRequest>, request the resource again or display a prompt to your user to try again.

### Thread Safety of Bundles

The <doc://com.apple.documentation/documentation/Foundation/Bundle/principalClass> property on <doc://com.apple.documentation/documentation/Foundation/Bundle> includes new thread-safety improvements. Accessing the property blocks if other threads are in the process of loading the bundle. This action allows the property to return the correct value in all cases.

### CFMessagePort

The <doc://com.apple.documentation/documentation/CoreFoundation/CFMessagePortSetName(_:_:)> function doesn’t do anything in apps linked on or after macOS 10.14, iOS 12, watchOS 5, and tvOS 12. This API will be deprecated in a future release.

In apps linked on earlier versions of macOS, iOS, watchOS, and tvOS, the <doc://com.apple.documentation/documentation/CoreFoundation/CFMessagePortSetName(_:_:)> function doesn’t do anything if the message port already has a dispatch queue associated with itself via the <doc://com.apple.documentation/documentation/CoreFoundation/CFMessagePortSetDispatchQueue(_:_:)> function. Previously, this pattern would result in undefined behavior.

In all cases, if you need to change the name of a <doc://com.apple.documentation/documentation/CoreFoundation/CFMessagePort>, use <doc://com.apple.documentation/documentation/CoreFoundation/CFMessagePortCreateLocal(_:_:_:_:_:)> or <doc://com.apple.documentation/documentation/CoreFoundation/CFMessagePortCreateRemote(_:_:)>.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)