Search code examples
iosrealmnsnumber

Crash when initializing realm object


I try initialize subclass of Realm Object, but in [super init] on field if (self && (_objectSchema = [self.class sharedSchema])) the app is crashes with follow message:

"Terminating app due to uncaught exception 'RLMException', reason: ''NSNumber' is not supported as an RLMObject property. Supported number types include int, long, float, double, and other primitive number types"

If anybody has any idea on how to debug this problem, please let me know.


Solution

  • Exception speaks for itself. You have NSNumber property on a RLMObject subclass and it is not listed in excluded properties. Probably you have it in a superclass of your object or in class extension.

    If you don't have that property on the class, it may be so that you have this property on some superclass/subclass. Maybe on the other RLMObject subclass. As you've noticed in the comments, crash also occurs when you [RLMRealm defaultRealm], this really points to the issue I describe. Two caveats:

    1. Even if you don't instantiate your subclass it is used to generate schema,
    2. Check ALL your RLMObject subclasses if they have any NSNumber property.