首页 > 学院 > 开发设计 > 正文

swift 开发 - NSDictionary与NSData互转、Dictionary与Data互转

2019-11-09 14:15:36
字体:
来源:转载
供稿:网友

1、NSDictionary转NSDatalet data:NSData =NSKeyedArchiver.archivedData(withRootObject:dataDic) asNSData2、NSData转NSDictionarylet dic =NSKeyedUnarchiver.unarchiveObject(with: dataas! Data)as! NSDictionary3、NSDictionary转Datalet date =try! JSONSerialization.data(withJSONObject: dic, options: .PRettyPrinted)4、Data转Dictionarylet json =try! JSONSerialization.jsonObject(with: data, options: .mutableContainers)as! Dictionary<String,String>


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表