Reputation: 20086
I am not sure why I am not able to make a reference to the child object properties from parent. Here is the relationship:
@class Vegetable;
@interface MyVegetableGarden : NSManagedObject
@property (nonatomic) NSTimeInterval datecreated;
@property (nonatomic) NSTimeInterval datemodified;
@property (nonatomic) BOOL active;
@property (nonatomic, retain) Vegetable *vegetable;
@end
And here is the Vegetable class:
#import <Foundation/Foundation.h>
#import <CoreData/CoreData.h>
@class VegetableCategory;
@interface Vegetable : NSManagedObject
@property (nonatomic, retain) NSString * about;
@property (nonatomic) BOOL active;
@property (nonatomic) NSTimeInterval dateCreated;
@property (nonatomic) NSTimeInterval dateModified;
@property (nonatomic, retain) NSString * imageURL;
@property (nonatomic, retain) NSString * name;
@property (nonatomic, retain) VegetableCategory *vegetableCategory;
@end
Now, I am trying to access the name property of the Vegetable class using the following code:
MyVegetableGarden *v = [[MyVegetableGarden alloc] init];
v.vegetable.name // For some reason the compiler says that name property is not found
Upvotes: 0
Views: 177
Reputation: 38728
I'm not sure you can create an NSManagedObject
like that :S
The docs state
If you instantiate a managed object directly, you must call the designated initializer (
initWithEntity:insertIntoManagedObjectContext:
).
Also see
Important: This method is the designated initializer for NSManagedObject. You must not initialize a managed object simply by sending it init.
Upvotes: 1
Reputation: 5473
Make sure you've #imported Vegetable.h in the file where you access the name property
Upvotes: 1