iOS技术文档No.1 AppKit_NSDataAsset

访问用特定格式存储在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类型的,不然读不出来

iOS技术文档No.1 AppKit_NSDataAsset_第1张图片
Data类型.png
iOS技术文档No.1 AppKit_NSDataAsset_第2张图片
Paste_Image.png
NSDataAsset *dataAsset=[[NSDataAsset alloc]initWithName:@"Data"];
    NSLog(@"%@---%@---%@",dataAsset.name,dataAsset.data,dataAsset.typeIdentifier);

控制台打印:

iOS技术文档No.1 AppKit_NSDataAsset_第3张图片
控制台.png

不过这东西让我想起了改变应用图标icon,这里附上一个改变icon的帖子 http://blog.csdn.net/qq_31810357/article/details/68489138

你可能感兴趣的:(iOS技术文档No.1 AppKit_NSDataAsset)