---
title: load()
framework: foundation
role: symbol
role_heading: Instance Method
path: foundation/bundle/load()
---

# load()

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

## Declaration

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

## Return Value

Return Value true if the method successfully loads the bundle’s code or if the code has already been loaded, otherwise false.

## Discussion

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() 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 initialize() class method of the principal class. Special Considerations If an NSBundle object calls the load() method, it calls the 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

### Related Documentation

- [principalClass](foundation/bundle/principalclass.md)
- [classNamed(_:)](foundation/bundle/classnamed(_:).md)

### Loading code from a bundle

- [executableArchitectures](foundation/bundle/executablearchitectures.md)
- [preflight()](foundation/bundle/preflight().md)
- [loadAndReturnError()](foundation/bundle/loadandreturnerror().md)
- [unload()](foundation/bundle/unload().md)
- [isLoaded](foundation/bundle/isloaded.md)
- [Mach-O Architecture](foundation/1495005-mach-o-architecture.md)
