<!--
{
  "availability" : [
    "iOS: 2.0.0 -",
    "iPadOS: 2.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.0.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/Bundle/load()",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSBundle(im)load"
  },
  "title" : "load()"
}
-->

# load()

Dynamically loads the bundle’s executable code into a running program, if the code has not already been loaded.

```
func load() -> Bool
```

## Return Value

<doc://com.apple.documentation/documentation/Swift/true> if the method successfully loads the bundle’s code or if the code has already been loaded, otherwise <doc://com.apple.documentation/documentation/Swift/false>.

## Discussion

You can use this method to load the code associated with a dynamically loaded bundle, such as a plug-in or framework. Prior to OS X version 10.5, a bundle would attempt to load its code—if it had any—only once. Once loaded, you could not unload that code. In macOS 10.5 and later, you can unload a bundle’s executable code using the [`unload()`](/documentation/Foundation/Bundle/unload()) method.

You don’t need to load a bundle’s executable code to search the bundle’s resources.

This method initializes the principal class in the bundle. To add code you want executed after loading, override the <doc://com.apple.documentation/documentation/ObjectiveC/NSObject-swift.class/initialize()> class method of the principal class.

### Special Considerations

If an `NSBundle` object calls the [`load()`](/documentation/Foundation/Bundle/load()) method, it calls the [`unload()`](/documentation/Foundation/Bundle/unload()) method before being deallocated. Therefore, you should retain any `NSBundle` object for as long as any code from it is used by the app.

## See Also

[`principalClass`](/documentation/Foundation/Bundle/principalClass)

The bundle’s principal class.

[`classNamed(_:)`](/documentation/Foundation/Bundle/classNamed(_:))

Returns the `Class` object for the specified name.



---

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)