I have a Person entity in Core Data model. I want to create a "friends" relationship conceptually which essentially is a self-referencing relationship (ie. expect friends fetch to return a list of "Person" objects. However, there is NO inverse relationship set.
I get the following exception:
app[7713:90b] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<Person 0xd55dd70> valueForUndefinedKey:]: the entity Person is not key value coding-compliant for the key "vprofiles".'
Question is, why does this cause an error, let alone an application crash? As an object graph, shouldn't this work out-of-the-box given its a common mapping pattern?
The App crashes on this line:
NSArray *friends = [[person valueForKey:@"vprofiles"] allObjects];
My Person interface generated is below.
@interface Person : NSManagedObject
@property (nonatomic, retain) NSDate * createdAt;
@property (nonatomic, retain) NSString * email;
@property (nonatomic, retain) NSDate * updatedAt;
@property (nonatomic, retain) NSString * username;
@property (nonatomic, retain) NSSet *vprofiles;
@end
@interface Person (CoreDataGeneratedAccessors)
- (void)addVprofilesObject:(Person *)value;
- (void)removeVprofilesObject:(Person *)value;
- (void)addVprofiles:(NSSet *)values;
- (void)removeVprofiles:(NSSet *)values;
@end