我遇到了同样的错误,但我已检查以确保在 .h 文件中正确设置了属性。
这是代码: NSUInteger theSizesCount = [theWho.theSizes count];
错误是“错误:在不是结构或联合的东西中请求成员 theSizes。这个 .m 文件正在导入 6 个 .h 文件,其中 4 个在 theWho 中具有相同的属性,但它与各种超类有关。这个 . m 文件只实现了其中一个,并且 theWho 和 theSize 是合成的。
此外,在这段代码中,theSizes 变量是绿色的,而 theWho 变量不是。另外,对于 NSUIntegers、NSMutableArray 等,该错误发生在多个地方。
我哪里错了?部分头文件代码如下。
// TheSize.h
@class TheWho;
@interface TheSize : NSManagedObject
{
}
@property (nonatomic, retain) NSString *name;
@property (nonatomic, retain) NSString *amount;
@property (nonatomic, retain) TheWho *theWho;
@property (nonatomic, retain) NSNumber *displayOrder;
@end
和..
//
// TheWho.h
//
@interface ImageToDataTransformer : NSValueTransformer {
}
@end
@interface TheWho : NSManagedObject {
}
@property (nonatomic, retain) NSString *instructions;
@property (nonatomic, retain) NSString *name;
@property (nonatomic, retain) NSSet *theSize;
@property (nonatomic, retain) UIImage *thumbnailImage;
@property (nonatomic, retain) NSManagedObject *image;
@property (nonatomic, retain) NSManagedObject *type;
@end
@interface TheWho (CoreDataGeneratedAccessors)
- (void)addTheSizesObject:(NSManagedObject *)value;
- (void)removeTheSizesObject:(NSManagedObject *)value;
- (void)addTheSizes:(NSSet *)value;
- (void)removeTheSizes:(NSSet *)value;
@end