如何将Jsonresult加载到另一个类
func getData(username:NSString) {
let URL = NSURL(string: (Config.apiUrl as String)+"/apiname?user_email=\(username)")
let req = NSURLRequest(URL: URL!)
print(req)
// let connection : NSURLConnection! = NSURLConnection(request: req, delegate: self, startImmediately: false)
NSURLConnection.sendAsynchronousRequest(req, queue: NSOperationQueue.mainQueue(), completionHandler: response)
}
func response(res: NSURLResponse?, data: NSData?, error: NSError?){
if (error != nil) {
}
var err: NSError
do{
let jsonResult = try NSJSONSerialization.JSONObjectWithData(data!, options:NSJSONReadingOptions(rawValue: 0))
guard let JSONDictionary :NSDictionary = jsonResult as? NSDictionary else {
print("Not a Dictionary")
// put in function
return
}
// print(TableData)
let status: String! = jsonResult["message"] as! NSString as String
if(status == "success"){
let json_candid_email = jsonResult["candid_email"] as? String
}
else{
print("NO Details")
}
}
catch let JSONError as NSError {
print("\(JSONError)")
}
}
我解析登录页面中的json值如何传递内部类