Here's a Swift example of doing a batch update in Core Data:
let updateRequest = NSBatchUpdateRequest("some_entity_name")
let predicateIsRead = NSPredicate(format: "isRead = %@", NSNumber(bool: true))
updateRequest.predicate = predicateIsRead
updateRequest.propertiesToUpdate = [
ContentItemAttributes.isRead.rawValue: NSNumber(bool: false)
]
updateRequest.resultType = NSBatchUpdateRequestResultType.UpdatedObjectsCountResultType
var error: NSError?
let updateResult = objectContext.executeRequest(updateRequest, error: &error) as NSBatchUpdateResult?
if let result = updateResult {
let count = result.result as Int
println("Updated \(count) rows")
} else {
println("Error during batch update: \(error?.localizedDescription)")
}Note that you'll need to update the objects in memory. The above code just prints the row count. If you have stuff displayed in the user interface, use this answer on Stack Overflow to adjust the above code.