<!--
{
  "availability" : [
    "macOS: 13.3.0 -",
    "swift: 5.1.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSWindowController/WindowLoading",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "s:So18NSWindowControllerC6AppKitE13WindowLoadingV"
  },
  "title" : "NSWindowController.WindowLoading"
}
-->

# NSWindowController.WindowLoading

A property wrapper that loads the receiver’s window.

```
@propertyWrapper struct WindowLoading<Value>
```

## Overview

Use this property wrapper on window controller properties that can be `nil` before the window controller’s window loads. Wrapping window controller properties this way eliminates crashes that can occur from implicitly defining properties as <doc://com.apple.documentation/documentation/Swift/Optional>, and then referencing them before the window controller finishes loading.

The following example uses the `NSWindowController.WindowLoading` property wrapper to ensure that `dateLabel` [`NSTextField`](/documentation/AppKit/NSTextField) loads before referencing it in the `didSet` of the `date` property observer:

```swift
class DateWindowController: NSWindowController {
    @WindowLoading private var dateLabel: NSTextField
    
    var date: Date? {
        didSet {
            let dateFormatter = DateFormatter()
            dateFormatter.dateStyle = .full
            let dateString = dateFormatter.string(from: self.date ?? Date())
            self.dateLabel.stringValue = dateString
        }
    }
}
```

After loading [`NSTextField`](/documentation/AppKit/NSTextField), the system can safely access and set the `date` property.

```swift
let dateWindowController = DateWindowController()
dateWindowController.date = Date()
```

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

```swift
@IBOutlet @WindowLoading private var dateLabel: NSTextField
```

## Topics

### Creating a WindowLoading Property Wrapper

[`init()`](/documentation/AppKit/NSWindowController/WindowLoading/init())

Creates an empty property wrapper that loads the window controller’s window before accessing the property.

[`init(wrappedValue:)`](/documentation/AppKit/NSWindowController/WindowLoading/init(wrappedValue:))

Creates a property wrapper that loads the window controller’s window before accessing the property.

## See Also

[`NSViewController.ViewLoading`](/documentation/AppKit/NSViewController/ViewLoading)

A property wrapper that loads the view controller’s view before accessing the property.



---

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)