我有一个可以使用SwiftyJSON解析的JSON:
if let title = json["items"][2]["title"].string {
println("title : \(title)")
}
功能完美。
但是我无法遍历它。我尝试了两种方法,第一种方法是
// TUTO :
//If json is .Dictionary
for (key: String, subJson: JSON) in json {
...
}
// WHAT I DID :
for (key: "title", subJson: json["items"]) in json {
...
}
XCode无法接受for循环声明。
第二种方法:
// TUTO :
if let appArray = json["feed"]["entry"].arrayValue {
...
}
// WHAT I DID :
if let tab = json["items"].arrayValue {
...
}
XCode无法接受if语句。
我做错了什么?
items
(例如标题、作者、评论),您会简单地重复if let <<newItem>> = item["<<newItem>>"].string {}
来捕获每个吗? - Craig.Pearce