↑クリックして拡大
↑クリックして拡大
↑クリックして拡大
↑クリックして拡大

頭痛が減ったので共有です!

rebuild.fmを応援しています!

HOME > NSData

NSData

基礎のデータ保有オブジェクトです。NSDataは静的なデータ保存、NSMutableDataは動的なデータを保有して、アプリケーション内のバイナリデータ保有に利用されます。知らない間に頻繁に利用しているクラスです。

NSURLのクラス階層

NSObject

NSData
・IOBluetoothSDPUUID
・NSMutableData

参考Appleサイト(英語): Foundation Framework Reference NSData Class Reference

NSDATA例文


//DictionaryからNSDataを生成する例
 var hogeDic: Dictionary = [:]
 hogeDic["swift"] = "salaryman";
 println(hogeDic);
 
 var hogeData:NSData = NSKeyedArchiver.archivedDataWithRootObject(hogeDic);
 println(hogeData);

 //おまけ:NSDataからNSDictionaryに変換する方法
 var hogeDicFromData: Dictionary = NSKeyedUnarchiver.unarchiveObjectWithData(hogeData) as Dictionary;
 println(hogeDicFromData);

 //ネットワークファイルからNSDataを生成する例
 let url = NSURL.URLWithString("http://swift-salaryman.com/files/image/page_top.gif");
 var err: NSError?;
 var imageData :NSData = NSData(contentsOfURL: url!,options: NSDataReadingOptions.DataReadingMappedIfSafe, error: &err);
 println(imageData);

↓こんな記事もありますよ!

2021-05-14 14:21:41

The pitfalls of Filetransfer in watchconnectivity on WatchOS. And how to avoid.

AppleWatch it succeeds with the actual machine, but if it is a simulator, it will fail、、、 When I...
2021-05-06 14:04:37

Line's animation stamp production pitfalls 、、、 failure story

I tried to make a LINE sticker during Golden Week. I made it and applied, but it was different f...
2021-04-22 14:54:53

Cool carousel carefully selected 3 points! Astringent image slider using WebGL.

I was on a trip to find a cool slider yesterday. It's simple, easy to use, and has a good de...
このエントリーをはてなブックマークに追加
右側のFacebookのLikeをクリック頂けると記事更新の際に通知されますので宜しければご利用下さい!