1、des加密解密
百度,问人,都没能把swift的des加密整出来,只有后面熟悉语言了自己再写,现在就只能通过使用oc的加密解密来实现des
在桥接头文件中importCommonCrypto.h文件(swift使用oc的,百度看看就能明白)
实例化
let decryptDES = CommonCrypto();
解密:
let json:NSString = decryptDES.getDecryptWithString(string,keyString: key,ivString: key);加密:
decryptDES.getEncryptWithString<span style="font-family: Menlo;">(string,ivString: key);</span>
这里用的3des,key用同一个
2:将json数据加载到字典中(我想用数据模型,可是我暂时不会)
do{ let json_b : AnyObject! = try NSJSONSerialization.JSONObjectWithData(data,options: NSJSONReadingOptions.AllowFragments) as! NSDictionary; print(json_b.objectForKey("Message")) if json_b.objectForKey("Result") as! String == "0"{ let Params : AnyObject! = json_b.objectForKey("Params") for var i=0;i<Params.count;++i{ var child = Dictionary<String,AnyObject>(); child["ACTIVITY_TITLE"] = Params[i].objectForKey("ACTIVITY_TITLE") as! String child["BEGIN_DATE"] = Params[i].objectForKey("BEGIN_DATE") as! String child["FIELD1"] = Params[i].objectForKey("FIELD1") as! String child["ITEM_KEY"] = Params[i].objectForKey("ITEM_KEY") as! String child["ORG_NAME"] = Params[i].objectForKey("ORG_NAME") as! String child["PRO_TITLE"] = Params[i].objectForKey("PRO_TITLE") as! String child["TASKID"] = Params[i].objectForKey("TASKID") as! String child["PRO_CODE"] = Params[i].objectForKey("PRO_CODE") as! String self.group[i] = child } dispatch_async(dispatch_get_main_queue(),{ () -> Void in self.loading.stopAnimating(); self.ordertableview.reloadData(); }) }else{ dispatch_async(dispatch_get_main_queue(),{ () -> Void in self.loading.stopAnimating(); self.login_alert((json_b.objectForKey("Message") as? String)!); }) } }catch{ dispatch_async(dispatch_get_main_queue(),{ () -> Void in self.loading.stopAnimating(); self.ordertableview.reloadData(); }) }
3、tableview刷新界面数据
dispatch_async(dispatch_get_main_queue(),{ () -> Void in self.ordertableview.reloadData(); })原文链接:https://www.f2er.com/swift/325063.html