Kádi Kádi - 1 year ago 60
Swift Question

Do not map Realm object into Realm table

Basically my problem is that I want to define a realm object (

subclass) and I do not want it to appear in the Realm database, instruct Realm to skip this one.

For example:

I want to implement a synchronisation logic in a private pod with dynamic list of objects that are all subclassed from an object, called

I have two classes that I register into my sync module (
) like
SyncModule.register([ConcreteClassA.self, ConcreteClassB.self])

Now Realm detects that I have 3
subclasses and creates 3 different tables.

I want a solution to instruct Realm, not to create the table for the
(intermediate object) class, like overriding a class function or something like that.

Answer Source

You'll want to override +[RLMObject shouldIncludeInDefaultSchema]. From Realm's source:

// Returns whether the class is included in the default set of classes persisted in a Realm.
+ (BOOL)shouldIncludeInDefaultSchema;