应用程序在从 api 解析 JSON 后反序列化结构时崩溃,将 xCode 更新到版本 9.3 后,崩溃开始出现,我无法弄清楚或诊断问题是什么或为什么会发生,崩溃或错误在这里发生它显示在下图中;
HANDYJSON/NominalTypeDescriptor/numberOfFields
import UIKit
import HandyJSON
import EventKit
class PlayersViewController:UIViewController{
var personsArray=[PersonData]()
func getAllPlayers(){
let params = ["id":"5"]
Communicator.performAsyncRequest(httpMethod: .post, apiName:Helper.sharedInstance().getActivityWithoutSyncID, parameters: params , showHUD: false) { (isSuccess, error, response, message) in
if isSuccess && response != nil {
let jsonData = try! JSONSerialization.data(withJSONObject: response as Any, options: JSONSerialization.WritingOptions.prettyPrinted)
let jsonString = NSString(data: jsonData, encoding: String.Encoding.utf8.rawValue)! as String
print(jsonString)
if let Persons = PersonStruct.deserialize(from: jsonString) {
if Persons.Status == "S200"{
for person in PersonsStruct.Data {
self.personsArray.append(person)
}
}
}
}
}
}
struct PersonStruct: HandyJSON {
var Status:String?
var Data=[PersonData]()
var Error = [String]()
var Extra = SyncActivityStructExtra()
}
struct PersonData:HandyJSON{
var id:String?
var name:String?
var phoneNumber:String?
}
提前致谢!