Search code examples
realm

How to statement RLMArray type add NSString


How can I statement a RLMArray for NSString type in Objective-C?

Like this:

@property RLMArray<Dog> *dogs;

Solution

  • From https://realm.io/docs/objc/latest/#many-to-many (since Realm 3.0.0+):

    RLMArrays can store primitive values in lieu of Realm objects. In order to do so, constrain a RLMArray with one of the following protocols: RLMBool, RLMInt, RLMFloat, RLMDouble, RLMString, RLMData, or RLMDate.

    So you need to use

    @property RLMArray<RLMString> *names;
    

    Notes for Realm-Objective-C 3.0.0:

    Querying RLMArrays containing values other than RLMObject subclasses is not yet implemented.