分析數據我無法獲得driverId從這個JSON如何從JSON數組
[data: [{"id":"619","driverId":"6789","starting_time":"2016-12-12 23:24:50","end_time":null}]]
這裏是我完整的代碼
//selector Method SESSION_STATUS_REQUEST_COMPLETE
func afterServiceStatus(notification : NSNotification) {
print(notification.userInfo!)
guard let data = notification.userInfo!["data"] else{
print("data have no idea ")
return
}
if let driverId = notification.userInfo![0]!["driverId"] {
print(driverId)
}
// if let driverId = data["driverId"] as? String{
//
// print(driverId)
// }
}
改變你的條件,這一個,如果讓driverId =數據![0]![ 「driverId」] { 打印(driverId) } –
你應該swiftyJSON看一看擺脫這種「! '瘋狂 – HaneTV
@SapanaRanipa強制刪除'!'後的數據然後運行時錯指令錯誤trowing –