0
我正在研究一個需要存儲服用藥丸時間的應用程序。隨着通知行動,我想存儲在CoreData
服用此藥的時間。這可能像這樣使用它作爲數組嗎?我的實體:在CoreData中存儲NSDate作爲數組
和通知動作:
func application(application: UIApplication, handleActionWithIdentifier identifier: String?, forLocalNotification notification: UILocalNotification, completionHandler:() -> Void) {
if identifier == "remindLater" {
print("remindLater")
notification.fireDate = NSDate().dateByAddingTimeInterval(60)
UIApplication.sharedApplication().scheduleLocalNotification(notification)
} else if identifier == "takePill" {
print("Pill taken")
do {
let results = try managedObjectContext.executeFetchRequest(fetchRequest)
for medicine in results {
medicine.timeArray.append(NSDate())
}
} catch let error as NSError {
print(error.userInfo)
}
}
completionHandler()
}