Friday, March 3, 2023



Use this property wrapper on view controller properties that can be nil before the view controller’s view loads. Wrapping view controller properties this way eliminates crashes that can occur from implicitly defining properties as Optional, and then referencing them before the view controller finishes loading.


Use this property wrapper over implicitly unwrapped optionals for IBOutlets as well.

This is introduced in the Xcode 14.3 beta but requires macOS 13.3 (still in beta) for deployment. So it will be a long time before many developers can use this, but it seems like the sort of thing you could reimplement yourself.

There are also NSWindowController.WindowLoading and UIViewController.ViewLoading.


1 Comment RSS · Twitter · Mastodon

These property wrappers can't be back-deployed because a property wrapper is a type, and types cannot be back-deployed (at least not without major effort).

When Swift gets accessor macros, it'll be possible to implement something like ViewLoading with a macro. The macro expansion won't need to call any new API, so it will back-deploy.

Leave a Comment