【发布时间】:2017-02-02 21:16:05
【问题描述】:
我正在尝试检查该应用是否已安装,如果已安装,请删除所有待处理的本地通知。我正在尝试使用此代码,但它似乎没有正确保存到我的核心数据中。
// check to see if the app has already been installed
let global = Global(context:coreDataStack.managedContext)
print("Has the app been installed before = \(global.wasLoaded)") // returns false
if(global.wasLoaded == false){
print("remove local notifications")
// remove all notifications
center.removeAllPendingNotificationRequests()
global.wasLoaded = true
coreDataStack.saveContext()
print("Has the app been installed before = \(global.wasLoaded)") // returns true
}
下次我运行该应用程序时,wasLoad 布尔值仍然返回为 false。 我是否在此处运行了获取请求以使其正常工作?
【问题讨论】:
标签: ios xcode core-data swift3