<!--
{
  "availability" : [
    "iOS: 9.0.0 -",
    "iPadOS: 9.0.0 -",
    "macCatalyst: 13.1.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/NSDataAsset",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSDataAsset"
  },
  "title" : "NSDataAsset"
}
-->

# NSDataAsset

An object from a data set type stored in an asset catalog.

```
class NSDataAsset
```

## Overview

The object’s content is stored as a set of one or more files with associated device attributes. These sets can also be tagged for use as on-demand resources.

### Initialize data assets

Data assets are initialized from a named data set in an asset catalog. You create data sets during app development. Each data set contains one or more data files. Each file has associated attributes for features of the device, including the minimum amount of memory and the version of Metal. When you initialize the data asset, the system selects the data file that best matches the current device.

For more information on the data set type in an asset catalog, see [Data Set Type](https://developer.apple.com/library/archive/documentation/Xcode/Reference/xcode_ref-Asset_Catalog_Format/DataSetType.html#//apple_ref/doc/uid/TP40015170-CH23) in [Asset Catalog Format Reference](https://developer.apple.com/library/archive/documentation/Xcode/Reference/xcode_ref-Asset_Catalog_Format/index.html#//apple_ref/doc/uid/TP40015170). For information on asset catalogs, see <doc://com.apple.documentation/documentation/Xcode/managing-assets-with-asset-catalogs>.

### Access the data

You access the data file by using the [`data`](/documentation/UIKit/NSDataAsset/data) property. Because the property is of type <doc://com.apple.documentation/documentation/Foundation/NSData> it provides methods for accessing the raw data only as bytes and ranges of bytes.

To access structured data, convert the bytes into the appropriate format. The system can convert some data types for you. One example is XML data using the <doc://com.apple.documentation/documentation/Foundation/XMLParser/init(data:)> method of <doc://com.apple.documentation/documentation/Foundation/XMLParser>. Other data types require code for parsing and converting the raw data. You may need to convert larger data files incrementally.

## Topics

### Initializing the data asset

[`init(name:)`](/documentation/UIKit/NSDataAsset/init(name:))

Initializes and returns an object with a reference to the named data asset in an asset catalog.

[`init(name:bundle:)`](/documentation/UIKit/NSDataAsset/init(name:bundle:))

Initializes and returns an object with a reference to the named data asset that’s in an asset catalog in the specified bundle.

### Accessing data

[`data`](/documentation/UIKit/NSDataAsset/data)

The raw data values in the data asset.

### Getting data asset information

[`name`](/documentation/UIKit/NSDataAsset/name)

The name of the data set in the asset catalog.

[`NSDataAssetName`](/documentation/UIKit/NSDataAssetName)

The name of a data asset.

[`typeIdentifier`](/documentation/UIKit/NSDataAsset/typeIdentifier)

The uniform type identifier for the data asset.



---

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)