小编Ani*_*til的帖子

如何从Swift中的NSDictionary获取单独的String数组中的所有键和值?

    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()
Run Code Online (Sandbox Code Playgroud)

好的,我在这里接收来自在线json的数据,然后将其存储为jsonresult中的NSDictionary.我需要将所有键和值分成两个独立的数组?

基本上我想要这个

jsonresult.allkeys - > String array
jsonresult.allvalues - > String array

arrays json ios swift

8
推荐指数
1
解决办法
1万
查看次数

标签 统计

arrays ×1

ios ×1

json ×1

swift ×1