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に格納しています。私は2つの別々の配列としてすべてのキーと値を取得する必要がありますか?SwiftのNSDictionaryからすべてのキーと値を別々の文字列配列に取得する方法は?
基本的に私はこの
jsonresult.allkeysたい - > String配列
jsonresult.allvalues - > String配列
タイプ ' NSData 'にメンバー' flatMap 'はありません –
@AniketPatil、修正済み、 'jsonData'ではなく' jsonResult'でなければなりません。 – Khundragpan