HOME > NSData
基礎のデータ保有オブジェクトです。NSDataは静的なデータ保存、NSMutableDataは動的なデータを保有して、アプリケーション内のバイナリデータ保有に利用されます。知らない間に頻繁に利用しているクラスです。
NSObject
↑
NSData
・IOBluetoothSDPUUID
・NSMutableData
//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... |
Tweet
![]() |
|||
|