我的应用程序崩溃并且它没有显示原因并且无法找到原因,崩溃发生在for循环中,循环运行并且它在第二次命中时如果条件然后仅崩溃。 请帮我找理由。
这里粘贴我的代码。
func removeDuplicatesFromOrderAndOpenOrder() {
let storedArray = NSMutableArray()
for i in 0..<logOrderMutArray.count {
let orderFipsValue:NSNumber = (logOrderMutArray[i] as AnyObject).value(forKey: "FIPS") as? NSNumber ?? 0
let orderAccountNumberValue:String = (logOrderMutArray[i] as AnyObject).value(forKey: "AccountNumber") as? String ?? ""
if i == 0 {
continue
}
for var j in 0..<openOrderMutArray.count {
let FipsValue:NSNumber = (openOrderMutArray[j] as AnyObject).value(forKey: "FIPS") as? NSNumber ?? 0 //----- > Thread 1 signal SIGABRT shows in this line.
let AccountNumberValue:String = (openOrderMutArray[j] as AnyObject).value(forKey: "AccountNumber") as? String ?? ""
if orderFipsValue == FipsValue && orderAccountNumberValue == AccountNumberValue {
let dictMutableCopy = logOrderMutArray[i] as! NSDictionary
let editDict = NSMutableDictionary(dictionary: dictMutableCopy)
let newDict = openOrderMutArray[j] as! NSDictionary
let newMutableArray = NSMutableArray()
newMutableArray.add(newDict)
editDict.setValue(newMutableArray, forKey: "Inspectionlist")
logOrderMutArray.replaceObject(at: i, with: editDict)
openOrderMutArray.removeObject(at: j)
j -= 1
}
else {
storedArray.add(openOrderMutArray[j])
logOrderMutArray.add(openOrderMutArray[j])
}
}
}
}