我不知道爲什麼我無法從父對象中引用子對象屬性。這裏的關係是:從父對象引用嵌套對象
@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