Core Data issue in iOS 7

Asked

Viewed 86 times

0

I have a problem between iOS 8 and iOS 7. I am using Core Data, I have an entity called Pessoa (NSManagedObject), only when doing a data update happens a EXC_BAD_ACCESS, only that, no other description or error more.

It happens in the following section:

let batchUpdateRequest = NSBatchUpdateRequest(entityName: "Company")

Strange because in the iOS 8 works normally and updates the data.

The code of the method 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
    }

I tried to change it to:

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

But all without success.

1 answer

3


You won’t be able to use the NSBatchUpdateRequest in the iOS 7, because this was only introduced in the iOS 8. Reference: iOS 8.0 Diffs API

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.