0
我有以下代码我的for循环的内容没有得到迅速执行3
if editingStyle == .delete{
let refreshAlert = UIAlertController(title: "Delete Collection", message: "All expenses in this collection will also be lost.", preferredStyle: UIAlertControllerStyle.alert)
refreshAlert.addAction(UIAlertAction(title: "Ok", style: .default, handler: { (action: UIAlertAction!) in
let collection = self.collections[indexPath.row]
CoreDataHelper.deleteCollection(collection: collection)
for expense in self.collectionExpensesDelete{
print ("deleted")
if expense.collection! == self.collections[indexPath.row].title{
CoreDataHelper.deleteExpense(expense: expense)
}
}
self.collections.remove(at: indexPath.row)
self.collections = CoreDataHelper.retrieveCollections()
}))
我想要做的就是删除,如果集合被删除相关的所有费用。然而,在中间的for循环,我放置它的断点不会被调用。只有“for”语句的初始断点被调用,并且不会调用其中的任何代码,包括delete语句。
谁能告诉我我做错了什么?
你在哪里记录?填充self.collectionExpensesDelete我认为其空 – 3stud1ant3
它是采用这样的核心数据填充: v ar collectionExpensesDelete = [Expense](){ didSet { tableSet.reloadData() } } –
我认为您只是初始化类型为Expense的空数组,您将在其中设置值,并确认其值空之前,循环添加打印(self.collectionExpensesDelete.count),并查看是否打印0 – 3stud1ant3