swift - Realm: Partially update -


i'm using realm in swift project , i'm having issues partially updating objects.

the problem have object contains information server plus user generated informations. in case topic can either visible or hidden default, user can change visibility value.

when launch app first time call server api fetch information create topic object: has visibility value undefined. user makes choice , set visibility value visible.

the second time launch application fetch info again server , recreate topic. call realm method add:update: update object updates visibility property undefined again.

i know there method create:value:update: means have create big dictionary values want update. model objects not small, in cases have lot of properties , dictionary huge. don't approach, complicated maintain.

do have hint on how handle case this?

a possibile way create object (table) has relationship topic , 1 property visibility not overridden when create topic again, sounds odd create table thing.

this easier solved if passing dictionary create:value:update: since omit visibility property, said size constraints, you're using new instance of model object has visibility set different value server response, can't helped. realm cannot tell wish keep particular property , change rest.

if you're using primary key, quickest fix fetch original object via primary key beforehand, make note of visibility property, , re-set after you've performed update.

breaking visibility property off own object work, you'd run same issue new object instance setting property nil.


Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

css - Can I use the :after pseudo-element on an input field? -