iOS Client: Have Model Detect Change to CBLJSONEncoding Instance in Array

25 views
Skip to first unread message

Pascal

unread,
Aug 6, 2014, 3:22:08 PM8/6/14
to mobile-c...@googlegroups.com
I'm trying to figure out if there's a better way than using my workaround in this situation: I have a preferences class (CBLModel subclass) which has a "reminders" property, an NSArray of Reminder objects which adheres to CBLJSONEncoding. Now whenever I change one of the reminder objects and then call "save:" on the preferences model, it doesn't re-encode the reminders because it doesn't know that it should re-save its "reminders" property. My workaround:

NSArray *reminders = _prefs.reminders;
_prefs.reminders = nil;
_prefs.reminders = reminders;

if (![_prefs save:&error]) {
    ...
}

I haven't found a way to mark a specific property dirty on the model, is there a way?

Cheers

Jens Alfke

unread,
Aug 7, 2014, 7:19:08 PM8/7/14
to mobile-c...@googlegroups.com

On Aug 6, 2014, at 12:22 PM, Pascal <phase.o...@gmail.com> wrote:

Now whenever I change one of the reminder objects and then call "save:" on the preferences model, it doesn't re-encode the reminders because it doesn't know that it should re-save its "reminders" property.

I think this is a case of issue #310, which Pasin is in the process of fixing. (Actually it looks like I need to code-review his fix.) If you want you can try his patch and see if it fixes your problem.

—Jens
Reply all
Reply to author
Forward
0 new messages