Class

NSDataAsset

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

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.

How Data Assets Are Initialized

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 in Asset Catalog Format Reference. For information on adding data sets to asset catalogs, see Adding Data Sets in Asset Catalog Help.

How Data Is Accessed

You access the data file by using the data property. Because the property is of type 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 initWithData: method of 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: String)

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

init?(name: String, bundle: Bundle)

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

Accessing Data

var data: Data

The raw data values in the data asset. (read-only)

Getting Data Asset Information

var name: String

The name of the data set in the asset catalog. (read-only)

var typeIdentifier: String

The uniform type identifier for the data asset. (read-only)

Type Aliases

Relationships

Inherits From

See Also

Assets

class UIImageAsset

A container for a collection of images that represent multiple ways of describing a single piece of artwork.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software