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类型的,不然读不出来

Data类型.png
Paste_Image.png
NSDataAsset *dataAsset=[[NSDataAsset alloc]initWithName:@"Data"];
    NSLog(@"%@---%@---%@",dataAsset.name,dataAsset.data,dataAsset.typeIdentifier);

控制台打印:

控制台.png

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

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • 发现 关注 消息 iOS 第三方库、插件、知名博客总结 作者大灰狼的小绵羊哥哥关注 2017.06.26 09:4...
    肇东周阅读 14,743评论 4 61
  • Swift版本点击这里欢迎加入QQ群交流: 594119878最新更新日期:18-09-17 About A cu...
    ylgwhyh阅读 25,722评论 7 249
  • 我去山河里找,铺就笔墨。 成就了我的,是你的名。 我乘风去的湖海… 风知道当时,我的志,我的誓。 它还知道,那句话...
    木土有阿杜阅读 1,355评论 0 1
  • 我们寻爱的过程 像是孤身一人 在黑暗里前行 遇见路灯 照亮了面前的路 给你勇气 却不能同行 遇见烟火 绚烂了整个天...
    花慕蓝阅读 2,939评论 1 1
  • 故事发生在前些天。公司组织一年一度的旅游(阳江闸坡),三个分店的人全部聚集在一起,而我纯属是实务者,虽然大...
    盛先森阅读 4,400评论 2 3

友情链接更多精彩内容