我有问题使用 @property 和 @synthesize 设置BOOL。我使用 @property BOOL isPaused得到; 键,我可以使用 [myObject的isPaused得到]得到它; ,但我不能管理来设置。我想使用 [myObject的setPaused:NO]; 。我也试过 @属性(setter方法= setPaused)BOOL isPaused得到; ,但如果我没有弄错的话,我需要编写自己设定器
I'm having problems setting a BOOL using @property and @synthesize. I'm using @property BOOL isPaused; And I can get it by using [myObject isPaused]; but I cannot manage to set it. I'd like to use [myObject setPaused: NO];. I also tried @property (setter=setPaused) BOOL isPaused; but if I'm not mistaking, then I need to write that setter myself.
推荐答案为什么不使用点符号?
myObject.isPaused = YES; return myObject.isPaused;如果你的财产被声明为 @property BOOL isPaused得到,然后设置器始终称为
[myObject setIsPaused:YES];要重命名的制定者必须提供完整的签名的包括冒号的:
To rename the setter you must provide the full signature including the colons:
@property(setter=setPaused:) BOOL isPaused; ... [myObject setPaused:YES];BTW,命名约定不包括在属性动词。
BTW, the naming convention is not to include verbs in a property.
@property(getter=isPaused) BOOL paused;更多推荐
@property制定者BOOL
发布评论