0
需要一些非常基本的幫助。Im新到swift並找不到任何好的解決方案。 我知道它非常基本的基礎,但是JSON和Swift更難,於是我想: 「)Alamofire解析和concat JSON在swift中
Alamofire.request("https://website.com/foobar").responseJSON { response in
let title = ""
var message = ""
if let result = response.result.value {
let JSON = result as! NSDictionary
print(JSON) // prints correctly the json
// {
// id: 29,
// title: "Foobar",
// email: "[email protected]",
// city: "Berlin",
// name: "John Doe",
// consumer_iban: null,
// updated_at: "2017-04-18 23:47:44"
// }
for(key,value) in JSON{
print("key \(key) value2 \(value)")
// this is correct shown too
}
}
但我想是這樣的:
if(key == "title") {
title = value;
}
else {
message += (\(key): \(value))
}
但是concatting並指的作爲重點串doensn't工作。