如果@protected是默认值,为什么这个ivar需要@protected? [英] Why does this ivar need @protected if @protected is the default?
问题描述
@interface AClass : SomeType {
@protected
NSMutableArray* amINotAlreadyProtected; //?
}
为什么此代码需要 @protected
如果 @protected
是默认值?这段代码是由一位非常有经验的程序员编写的,但我自己会省略说明符。
Why does this code need @protected
if @protected
is the default? This code was written by a very experienced programmer, but I would omit the specifier myself.
推荐答案
不需要用于关键字 @protected
,因为它是默认行为。
There is no need for the keyword @protected
as it is the default behavior.
然而,一些程序员倾向于无论如何,请使用它,因为一个经验不足的程序员会在以后出现并且不知道这一点。还可以提到的是,它增加了代码的可读性,因为有些变量受到保护,而其他私有或公共变量。
However, some programmers tend to use it anyways incase a less experienced programmer comes along at a later date and doesn't know this. It can also be mentioned that it increase code readability incase there are some variables that are protected and other private or public.
这篇关于如果@protected是默认值,为什么这个ivar需要@protected?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!