<!--
{
  "availability" : [
    "iOS: 4.0.0 -",
    "iPadOS: 4.0.0 -",
    "macCatalyst: 13.1.0 -",
    "tvOS: -",
    "visionOS: 1.0.0 - 1.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UINib/init(data:bundle:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)UINib(cm)nibWithData:bundle:"
  },
  "title" : "init(data:bundle:)"
}
-->

# init(data:bundle:)

Creates a nib object from nib data stored in memory.

```
init(data: Data, bundle bundleOrNil: Bundle?)
```

## Parameters

`data`

A block of memory that contains nib data.

`bundleOrNil`

The bundle in which to search for resources referenced by the nib. If you specify `nil`, this method looks for the nib file in the main bundle.

## Return Value

The initialized [`UINib`](/documentation/UIKit/UINib) object. An exception is thrown if there were errors during initialization or the nib data could not be located.

## Discussion

The [`UINib`](/documentation/UIKit/UINib) object looks for the nib file in the bundle’s language-specific project directories first, followed by the `Resources` directory.

The preferred mechanism for instantiating [`UINib`](/documentation/UIKit/UINib) objects is with [`init(nibName:bundle:)`](/documentation/UIKit/UINib/init(nibName:bundle:)). A [`UINib`](/documentation/UIKit/UINib) object instantiated using [`init(data:bundle:)`](/documentation/UIKit/UINib/init(data:bundle:)) can’t release the cached data under low memory conditions. Your app should prepare to release the [`UINib`](/documentation/UIKit/UINib) object and the data under low memory conditions, recreating both the next time the app needs to instantiate the nib.

---

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)