访问用特定格式存储在asset catalog里面的一个对象,这是iOS9 SDK的新类,用于操作asset Category文件的。
- (instancetype)init NS_UNAVAILABLE;
/// Equivalent to -initWithName:name bundle:[NSBundle mainBundle];
- (nullable instancetype)initWithName:(NSString *)name;
/// Create a data asset with the given name from the given bundle. Returns nil if the asset was not found.
- (nullable instancetype)initWithName:(NSString *)name bundle:(NSBundle *)bundle NS_DESIGNATED_INITIALIZER;
/// The name used to reference the data asset
@property (nonatomic, readonly, copy) NSString *name;
/// The data for this asset, as stored in the asset catalog
@property (nonatomic, readonly, copy) NSData *data;
/// The Uniform Type Identifier for this data object.
@property (nonatomic, readonly, copy) NSString *typeIdentifier;
这里要特别注意一下,你在asset里建的文件一定是Data类型的,不然读不出来
NSDataAsset *dataAsset=[[NSDataAsset alloc]initWithName:@"Data"];
NSLog(@"%@---%@---%@",dataAsset.name,dataAsset.data,dataAsset.typeIdentifier);
控制台打印:
不过这东西让我想起了改变应用图标icon,这里附上一个改变icon的帖子http://blog.csdn.net/qq_31810357/article/details/68489138