Problem with Core Data on iOS 7

0

I have a problem between iOS 8 and iOS 7. I am using Core Data, I have an entity called Pessoa ( NSManagedObject ), but when performing an update on the data happens a EXC_BAD_ACCESS , only this, no further description or error.

It happens in the following section:

let batchUpdateRequest = NSBatchUpdateRequest(entityName: "Company")

Strange because iOS 8 usually works and updates the data.

The method code is basically:

func update (people: People) {
        var error: NSErrorPointer = nil

        //O erro ocorre aqui
        let batchUpdateRequest       = NSBatchUpdateRequest(entityName: "People")

        batchUpdateRequest.predicate = NSPredicate(format: "idObject == \(people.idObject)")            
        batchUpdateRequest.propertiesToUpdate = [
            "name" : people.name,
            "phone" : people.phone,
            "address" : people.address,
            "email" : people.email
        ]
        batchUpdateRequest.resultType = NSBatchUpdateRequestResultType.UpdatedObjectsCountResultType
        let result = managedObjectContext?.executeRequest(batchUpdateRequest, error: error) as NSBatchUpdateResult
    }

Already tried changing to:

let batchUpdateRequest = NSBatchUpdateRequest(entityName: "Company" as NSString)

But all to no avail.

    
asked by anonymous 20.02.2015 / 11:54

1 answer

3

You will not be able to use NSBatchUpdateRequest in iOS 7 because it was only introduced in iOS 8 . Reference: iOS 8.0 API Diffs

In iOS 7 you will have to do iterate between the objects and make the changes one by one.

    
20.02.2015 / 13:40