我不确定我是在错误地使用字典还是数据对象,或者两者都有误。我正在尝试适应切换到Swift,但我遇到了一些小麻烦。
var dictionaryExample : [String:AnyObject] =
["user":"UserName",
"pass":"password",
"token":"0123456789",
"image":0] // image should be either NSData or empty
let dataExample : NSData = dictionaryExample as NSData
我需要将NSDictionary
编码为一个NSData
对象,同时还需将该NSData
对象解码为NSDictionary
。
非常感谢任何帮助。