How to save a struct to realm in swift? -
it easy use realm classes inheriting object
. how save struct
containing several fields realm in swift? e.g.
struct datamodel { var id = 0 var test = "test" }
i know documentation clear supported types. maybe there nice workaround or - better - realm write future plans structs.
to save struct
in realm, means copying data realm object
. reason why realm objects
classes , not structs
because not inert values, auto-updating objects represent persisted data in realm. has practical benefits, such fact realm object
's data lazy loaded.
you can take advantage of realm's approach responding change notifications realm instance. example if uitableview
data source based off array property on realm object
, long have instance of object, guaranteed after notification represents correct values. used can simplify code versus having multiple copies of values structs.
Comments
Post a Comment