【发布时间】:2015-11-13 21:15:10
【问题描述】:
我正在开发一个需要存储服药时间的应用程序。通过通知操作,我想将服用此药的时间存储在CoreData。这可以像这样使用它作为数组吗?我的实体:
和通知操作:
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()
}
【问题讨论】:
标签: ios arrays swift core-data