我不知道为什么我无法从父对象中引用子对象属性。这里的关系是:从父对象引用嵌套对象
@class Vegetable;
@interface MyVegetableGarden : NSManagedObject
@property (nonatomic) NSTimeInterval datecreated;
@property (nonatomic) NSTimeInterval datemodified;
@property (nonatomic) BOOL active;
@property (nonatomic, retain) Vegetable *vegetable;
@end
,这里是蔬菜类:
#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
现在,我尝试使用下面的代码来访问蔬菜类的名称属性:
MyVegetableGarden *v = [[MyVegetableGarden alloc] init];
v.vegetable.name // For some reason the compiler says that name property is not found
您是否正在导入Vegetable和MyVegetableGarden? – 2011-12-30 01:40:33