xcode 属性的合成 getter 遵循可可命名约定以返回“拥有的”对象

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15743130/
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-15 03:06:25  来源:igfitidea点击:

property's synthesized getter follows cocoa naming convention for returning 'owned' objects

objective-cxcodenaming-conventions

提问by KoKo HL Apinyanont

I curious is cocos2d have any naming convention for variable?

我很好奇 cocos2d 对变量有什么命名约定吗?

I have this

我有这个

//.h
NSMutableArray *newRowForCounter;

and

//.m
@synthesize newRowForCounter;

and at @synthesize it's warning "property's synthesized getter follows cocoa naming convention for returning 'owned' objects" but if I change the name to something else it work fine.

在@synthesize 处警告“属性的合成 getter 遵循可可命名约定以返回“拥有的”对象”,但如果我将名称更改为其他名称,则它可以正常工作。

I also try out variable naming begin with new- {EX newVariable...) it's still warn me that.

我还尝试以 new- {EX newVariable...) 开头的变量命名,它仍然警告我。

Thank

谢谢

My gamma may look bad sorry about that

我的伽马可能看起来很糟糕,对此感到抱歉

回答by Lithu T.V

new cannot be used in the variable name at the beginning. That is why it shows the error.

变量名开头不能使用new。这就是它显示错误的原因。

Sol : declare a property whose name begins with new unless you specify a different getter:

Sol :除非您指定不同的 getter,否则声明名称以 new 开头的属性:

// Won't work:
@property NSString *newTitle;

// Works:
@property (getter=theNewTitle) NSString *newTitle;

Explanations hereand here

这里这里的解释