NSData class enables you to access an object from a data set type stored in an asset catalog. 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.
- iOS 9.0+
- macOS 10.11+
- tvOS 9.0+
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
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
init method of
XMLParser. Other data types require code for parsing and converting the raw data. You may need to convert larger data files incrementally.