Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query on RLMArray containing NSString crashes. #5785

Closed
Gawetaner opened this issue May 29, 2018 · 3 comments
Closed

Query on RLMArray containing NSString crashes. #5785

Gawetaner opened this issue May 29, 2018 · 3 comments

Comments

@Gawetaner
Copy link

Goals

Query all objects that contain a specific string in a RLMArray property.

Expected Results

The result contains all objects which contain the specific string in their RLMArray property.

Actual Results

The query throws an exception:

Expected object of type (null) for property 'strings' on object of type 'RealmObject', but received: 1

Steps to Reproduce

  1. Create a new ObjC iOS Project
  2. Add Realm as dependency
  3. Paste the sample code into AppDelegate.m
  4. Start the App

Code Sample

#import "AppDelegate.h"

// Frameworks
#import <Realm/Realm.h>

@interface RealmObject : RLMObject

@property (nonatomic) RLMArray <NSString *> <RLMString> *strings;

@end

@implementation RealmObject

+ (NSArray<NSString *> *)requiredProperties
{
    return @[NSStringFromSelector(@selector(strings))];
}

@end

@interface AppDelegate ()

@end

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    RealmObject *object1 = [RealmObject new];
    [object1.strings addObjects:@[@"1"]];

    RealmObject *object2 = [RealmObject new];
    [object2.strings addObjects:@[@"2"]];

    RealmObject *object3 = [RealmObject new];
    [object3.strings addObjects:@[@"3"]];

    RLMRealm *realm = [RLMRealm defaultRealm];
    [realm transactionWithBlock:^{
        [realm deleteAllObjects];
        [realm addObjects:@[object1, object2, object3]];
    }];
    
    RLMResults *results = [RealmObject objectsWhere:@"%@ IN SELF.strings", @"1"];
    NSLog(@"%@", results);
    
    return YES;
}
@end

Version of Realm and Tooling

ProductName:	Mac OS X
ProductVersion:	10.13.4
BuildVersion:	17E202

/Applications/Xcode_9.3.0.app/Contents/Developer
Xcode 9.3
Build version 9E145

/Users/gawetaner/.rbenv/shims/pod
1.5.3
Realm (3.5.0)
Realm (~> 3.5)

/bin/bash
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin17)

carthage not found
(not in use here)

/usr/local/bin/git
git version 2.17.0
@zntfdr
Copy link
Contributor

zntfdr commented Jun 14, 2018

I am in the same exact situation, did you solve it?

@zntfdr
Copy link
Contributor

zntfdr commented Sep 7, 2018

Any update in this? @jpsim

@jsflax
Copy link
Contributor

jsflax commented Nov 2, 2019

Duplicate of #5334.

@jsflax jsflax closed this as completed Nov 2, 2019
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants