0
我的代碼是這個類型任何沒有下標構件迅速3
import UIKit
import Alamofire
class ViewController: UIViewController {
var young = "https://jsonplaceholder.typicode.com/posts"
override func viewDidLoad() {
super.viewDidLoad()
callAlamo(url: young)
}
func callAlamo(url: String){
Alamofire.request(url).responseJSON { (response) in
let responseJSON = response.data
if responseJSON == nil{
print("response is empty")
}else{
print("Jon is \(responseJSON)")
self.parseJson(JSONData: responseJSON!)
}
}
}
func parseJson(JSONData: Data){
do{
let readableJSON = try JSONSerialization.jsonObject(with: JSONData, options: .mutableContainers)
for i in 0..<(readableJSON as AnyObject).count{
print(readableJSON[i] as String)
}
}catch{
print(error)
}
}
}
我需要此JSON內的每個數組元素。
有關於非常相同的錯誤信息>> 20個問題。請檢查您的問題是否未被回答。 –
你能告訴我你的JSON,你正在獲得表單服務嗎? –