gpt4 book ai didi

swift - 做声明

转载 作者:搜寻专家 更新时间:2023-11-01 07:13:12 25 4
gpt4 key购买 nike

<分区>

假设这是我们从模型中删除对象的函数:

func delete(indexPath: IndexPath) {

let managedObject = self.fetchedResultsController.object(at: indexPath)
self.managedObjectContext.delete(managedObject)

do {

// Save changes
try self.managedObjectContext.save()

// Cancel the notification
let center = UNUserNotificationCenter.current()
center.removeDeliveredNotifications(withIdentifiers: [managedObject.uuid!])
center.removePendingNotificationRequests(withIdentifiers: [managedObject.uuid!])

// Reload tableView
self.tableView.reloadData()

} catch {

let alertController = UIAlertController.init(title: "Error", message: "We are sorry! Unknown error occured...", preferredStyle: .alert)
alertController.addAction(UIAlertAction.init(title: "Close", style: .default, handler: { (action) in
// Completion handler
}))
self.present(alertController, animated: true, completion: {
// Completion block
})
}
}

问题:

如果抛出错误,执行将转移到 catch 子句。那很好。但是语句(其余代码,取消通知和重新加载 tableView)会发生什么?这些语句仍然是可执行的还是被简单地忽略了?

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com