I've been trying to write a query to access an object equal to a specific key for a while without success. I've already looked through SO & Realm documentation without any luck.
If I print out the structure of the CachedCodes RLMObject, it looks like this:
CachedCodes {
Codes = Codes {
assets = RLMArray<KVString> (
[0] KVString {
key = Some Key;// this is what I'd want to query for
value = Some Value;
}
);
};
}
Here's my class structure:
@interface CachedCodes : RLMObject
@property (nonatomic, strong, readonly) Codes *Codes;//readwrite in .m
@end
@interface Codes : RLMObject
@property (nonatomic, strong, readonly) RLMArray<KVString *><KVString> *assets;//readwrite in .m
@end
@interface KVString : RLMObject
@property (nonatomic, strong, readonly) NSString *key;//readwrite in .m
@property (nonatomic, strong, readonly) NSString *value;//readwrite in .m
@end
RLM_ARRAY_TYPE(KVString);
Here's what I've tried:
[CachedObjects objectsWhere:@"Codes.assets.key == 'Some key'"];
Error: Key paths that include an array property must use aggregate operations.
[CachedObjects objectsWhere:@"Codes.assets.key IN 'Some key'"];
Error: Key paths that include an array property must use aggregate operations.
[CachedObjects objectsWhere:@"ANY Codes.assets.key == 'Some key'"];
Error: No error. It doesn't crash, nor does it give me the objects with key "Some key". Instead, it gives me all of the objects.
If anyone has any input, I'd be forever grateful :)
KVStringobject whose value forkeymatches your desired string? - christopherdrum