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

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容

  • 發現 關注 消息 iOS 第三方庫、插件、知名博客總結 作者大灰狼的小綿羊哥哥關注 2017.06.26 09:4...
    肇東周閱讀 12,229評論 4 61
  • Swift版本點擊這里歡迎加入QQ群交流: 594119878最新更新日期:18-09-17 About A cu...
    ylgwhyh閱讀 25,546評論 7 249
  • 我去山河里找,鋪就筆墨。 成就了我的,是你的名。 我乘風去的湖海… 風知道當時,我的志,我的誓。 它還知道,那句話...
    木土有阿杜閱讀 170評論 0 1
  • 我們尋愛的過程 像是孤身一人 在黑暗里前行 遇見路燈 照亮了面前的路 給你勇氣 卻不能同行 遇見煙火 絢爛了整個天...
    花慕藍閱讀 358評論 1 1
  • 故事發生在前些天。公司組織一年一度的旅游(陽江閘坡),三個分店的人全部聚集在一起,而我純屬是實務者,雖然大...
    盛先森閱讀 899評論 2 3