Reputation: 143
I am looking to add properties to realm class that is defined in an external data source. Looking for advise on how to add properties on the fly. Goal is to make the REALM class representation flexible.
example:
class MyClass:RLMObject
@property var1
@property var2
added property data source = @[@"var3",@"var4"]
looking to read this property data source and enhance my class in run-time to be
class MyClass:RLMObject
@property var1
@property var2
@property var3
@property var4
Also, interested if there are other ways to achieve flexible data model persistence in REALM without updating the class in run-time.
Thanks in advance.
Upvotes: 2
Views: 572
Reputation: 755
The Browser is a separate project in the same repo under tools, it's an app that can be used to look at Realm files. The editing-arrays branch of this app does some things dynamically, although it doesn't edit schemas during runtime. That is however something that will come to both the Browser and the bindings in the future.
To get an idea on how to use the existing dynamic functionality you should check out the Migration and Dynamic tests here:
https://github.com/realm/realm-cocoa/tree/master/Realm/Tests
EDIT: This was meant as a comment, not an answer!
Upvotes: 0
Reputation: 1578
Brian from Realm here.
The current API is built on top of a dynamic API :-). We do plan to support this with a more public API. Until then it's possible to use the one used for migrations and the private API used by the Realm Browser: https://github.com/realm/realm-cocoa/tree/master/tools/RealmBrowser. But be aware that API will likely change!
Upvotes: 1