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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7005390/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 21:41:52  来源:igfitidea点击:

Synthesize error "Missing Context for Property Implementation Declaration"

xcodepropertiesdeclaration

提问by rreichel

Anyone have any ideas? When I try to synthesize a property I have declared in the .h file its not letting me synthesize it. Any ideas? Thanks!

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

回答by mamills

This can happen when you attempt to synthesize a property outside of the scope of your class' implementation.

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

Incorrect:

不正确:

@synthesize yourProperty;
@implementation YourClass
@end

Correct:

正确的:

@implementation YourClass
@synthesize yourProperty;
@end

回答by Jian

It often happen when you use #import,and does not on the top of file.

它经常发生在您使用#import, 并且不在文件顶部时。