【发布时间】:2016-08-07 07:27:19
【问题描述】:
let urlAsString = "https://drive.google.com/uc?export=download&id=0B2bvUUCDODywWTV2Q2IwVjFaLW8"
let url = NSURL(string: urlAsString)!
let urlSession = NSURLSession.sharedSession()
let jsonQuery = urlSession.dataTaskWithURL(url, completionHandler: { data, response, error -> Void in
do {
if let jsonDate = data, let jsonResult = try NSJSONSerialization.JSONObjectWithData(jsonDate, options: []) as? NSDictionary {
print(jsonResult)
}
} catch let error as NSError {
print(error)
}
})
jsonQuery.resume()
好的,我在这里从在线 json 接收数据,然后将其作为 NSDictionary 存储在 jsonresult 中。我需要将所有键和值放入两个单独的数组中?
基本上我想要这个
jsonresult.allkeys --> 字符串数组
jsonresult.allvalues --> 字符串数组
【问题讨论】: