Search code examples
objective-crealm

Realm RLMArray is nil


For some reason my RLMArray's are nil when I run my program. I am able to see the data in the RLM browser, and it links appropriatley.

Is there something I could be missing here?

@interface HMFAlbum : RLMObject

@property NSInteger persistentId;

@property RLMArray<HMFTrack> *tracks;
@property RLMArray<HMFRange> *ranges;

@end

@interface HMFTrack : RLMObject

@property NSInteger persistentId;
@property HMFAlbum *album;

@end

RLM_ARRAY_TYPE(HMFTrack)

@interface HMFRange : RLMObject

@property NSInteger persistentId;
@property (readonly) RLMLinkingObjects *albums;

@end

RLM_ARRAY_TYPE(HMFRange)

enter image description here

enter image description here


Solution

  • It's expected that instance variables of persisted RLMObject instances will be nil as the property getters read values directly from the Realm file. The instance variables are only used for objects prior to being saved to the Realm, and remain nil after that point.

    The Debugging section of the Realm documentation touches on this topic and mentions an LLDB script that can be used to show property values of persisted objects when debugging in Xcode. The -description method on the model classes, used by NSLog when formatting objects using the %@ format specifier, will also show the property values as expected.