0

I'm running into a problem with updating objects in my local backing store in my iOS app. Lets say I have an object (in JSON format)

{
  attr1: 'Hello',
  attr2: 'World'
}

The corresponding NSManagedObject in my iOS app has two attributes: NSString *attr1 and attr2. On this initial JSON push, the object gets the correct values 'Hello' and 'World' in attr1 and attr2. The next from my backend server message returns the following JSON:

{
  attr1: 'Hello2'
}

This updates my object's attr1 to 'Hello2', but my attr2 stays the same (i.e. 'World'). I want this to be nullified. In other words, I don't want an 'update' to my NSManagedObject, but rather I want a full reset. Is there a way to accomplish this? I have tried a few things like explicitly nullifying attributes and saving the NSManagedObjectContext, but this way doesn't seem to persist. Am i missing anything?

DarezGhost
  • 59
  • 11

1 Answers1

1

You are doing the right thing. Nullify "manually" (or by automating this inside the NSManagedObject subclasses), and save to persist.

If you are not seeing what you expect the error must be in the way you are saving, or in the way you are showing the data. Or maybe your object got updated again before being shown.

Mundi
  • 79,884
  • 17
  • 117
  • 140