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