Learn how to edit and delete objects in Core Data and how to handle relationships when deleting objects.
This is a companion discussion topic for the original entry at https://www.raywenderlich.com/3813-beginning-core-data/lessons/6
Learn how to edit and delete objects in Core Data and how to handle relationships when deleting objects.
I am trying to do the update request with following code. But it is not being updated. What i am doing wrong?
let deviceUpdateRequest = NSBatchUpdateRequest(
entityName: “Device”)
deviceUpdateRequest.resultType = .UpdatedObjectIDsResultType
deviceUpdateRequest.predicate = nil
deviceUpdateRequest.propertiesToUpdate = [“deviceType”:“iphone”]
do {
let deviceResult =
try managedObjectContext.executeRequest(deviceUpdateRequest)
as! NSBatchUpdateResult
let alert = UIAlertController(title: "Batch Update Succeeded",message: "\(deviceResult.result!.count!) device records updated.",
preferredStyle: .Alert)
alert.addAction(UIAlertAction(title: "OK",
style: .Cancel, handler: nil))
presentViewController(alert, animated: true, completion: nil)
} catch {
let alert = UIAlertController(title: "Batch Update Failed",
message: "There was an error with the batch update.",
preferredStyle: .Alert)
alert.addAction(UIAlertAction(title: "OK",
style: .Cancel, handler: nil))
presentViewController(alert, animated: true, completion: nil)
}
Hi … you should check challenge documentation, because there’re many mistakes:
fatal error: unexpectedly found nil while unwrapping an Optional value
Hi, I have simple question, how to make auto increment field in core data