Skip to content

"-[PFObject <FIELD NAME>]: unrecognized selector sent to instance" when accessing field of related object #3

Open

Description

@hokster7

I've got two ParseModel subclasses: Foo and Bar.
Foo holds an instance of Bar like so:

@interface Foo : ParseModel
@property(nonatomic, strong) Bar *bar;
@end

@interface Bar : ParseModel
@property(nonatomic, strong) NSNumber *theAnswer;
@end

I fetch all Foos. I want to assert some properties about bars

        PFQuery *query = [PFQuery queryWithClassName:@"Foo"];
        query.cachePolicy = kPFCachePolicyCacheThenNetwork;
        [query includeKey:@"bar"];
        [query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
            // Print information about foos.
            Foo *foo = objects[0];
            expect(foo.bar).to.beInstanceOf([Bar class]); // FAILS: expected Bar but was actually PFObject
            expect(foo.bar.theAnswer).to.equal(@42); // -[PFObject theAnswer]: unrecognized selector sent to instance...
        }];

What's the expected behaviour here? Must I marshall PFObjects in and out of those properties myself?

Activity

  1. hokster7 commented on Sep 13, 2014

    @hokster7
    Author

    Oh, I didn't know you had to call +registerParseModel on every ParseModel class!
    Perhaps the README could have a section on this.

  2. hokster7 commented on Sep 14, 2014

    @hokster7
    Author

    Okay... this is tré strange. +registerParseModel did make my test succeed yesterday, but now it doesn't work...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions