我刚刚将我的项目转换为 swift 4,但是当我使用 SWXMLHash 模拟我的应用程序时出现错误:
var code: Int! = nil
var message: String! = nil
var paramsContent: String! = nil
let xmlStrData = SWXMLHash.lazy(strData)
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "yyyy-MM-dd"
let appDel: AppDelegate = UIApplication.shared.delegate as! AppDelegate
let context: NSManagedObjectContext = appDel.managedObjectContext
let simulationParamsDescription = NSEntityDescription.entity(forEntityName: "SimulationParams", in: context)
let simulationParams = NSManagedObject(entity: simulationParamsDescription!, insertInto: context)
code = Int((xmlStrData["SOAP-ENV:Envelope"]["SOAP-ENV:Body"]["ns1:GetSimulationParamsResponse"]["GetSimulationParamsReturn"]["code"].element?.text)!)!
message = xmlStrData["SOAP-ENV:Envelope"]["SOAP-ENV:Body"]["ns1:GetSimulationParamsResponse"]["GetSimulationParamsReturn"]["message"].element?.text
当我尝试获取代码节点值时,出现此错误:
EXC_BAD_INSTRUCTION(代码=EXC_I386_INVOP,子代码=0x0)