Skip to content

Instantly share code, notes, and snippets.

@wisaruthk
Created October 7, 2015 10:05
Show Gist options
  • Save wisaruthk/9ab481712cfbf2e16e12 to your computer and use it in GitHub Desktop.
Save wisaruthk/9ab481712cfbf2e16e12 to your computer and use it in GitHub Desktop.
Swift NSBatchUpdateRequest
let batchRequest = NSBatchUpdateRequest(entityName: "Group")
batchRequest.predicate = NSPredicate(format: "SELF != %@", self.group!)
batchRequest.propertiesToUpdate = ["isFirstView":NSNumber(bool: false)]
batchRequest.resultType = .UpdatedObjectsCountResultType
do {
let results:NSBatchUpdateResult = try managedContext.executeRequest(batchRequest) as! NSBatchUpdateResult
print("update with result = \(results.result)")
} catch {
print("Error something..")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment