合成错误“缺少属性实现声明的上下文”

时间:2011-08-10 02:58:36

标签: xcode properties declaration

有人有什么想法吗?当我尝试合成我在.h文件中声明的属性时,它不让我合成它。有任何想法吗?谢谢!

2 个答案:

答案 0 :(得分:54)

当您尝试合成类实现范围之外的属性时,可能会发生这种情况。

不正确:

@synthesize yourProperty;
@implementation YourClass
@end

正确:

@implementation YourClass
@synthesize yourProperty;
@end

答案 1 :(得分:0)

通常在您使用#import时发生,而不是在文件顶部。