[Solved] Store string type array in RealM objective c


You can inherit from RLMObject class and put the NSString into your RLMObject as a property.
Then you can make new RLMObject one more time, with a RLMArray of previously made RLMObject now.

@interface StringObject: RLMObject
@property NSString *stringValue;
@end

@interface RealmObject: RLMObject
@property RLMArray<StringObject> *realmArray
@end

After this manipulation feel free to use it. F.e. use fast enumeration loop to put the strings into realm RLMArray.

NSArray *arrayOfStrings = @[@"58575bc922e87bd14480132f",@"58575c5c22e87bd144801331",@"58575cc922e87bd144801333",@"58575d5b22e87bd144801335",@"58575bc922e87bd14480132f",@"58575c5c22e87bd144801331",@"58575cc922e87bd144801333",@"58575d5b22e87bd144801335",@"58575bc922e87bd14480132f",@"58575c5c22e87bd144801331",@"58575cc922e87bd144801333",@"58575d5b22e87bd144801335"];

RLMRealm *realm = [RLMRealm defaultRealm];

RealmObject *realmObject = [RealmObject new];
for (NSString *value in arrayOfStrings) {
    StringObject *string = [StringObject new];
    string.stringValue = value;

    [realmObject.realmArray addObject:string];
}

[realm beginWriteTransaction];
[realm addObject:realmObject];
[realm commitWriteTransaction];

Thanks to RLMObject with Array of NSStrings
And
https://github.com/realm/realm-cocoa/issues/3415

4

solved Store string type array in RealM objective c