@property制定者BOOL [英] @property setter for BOOL

查看:347
本文介绍了@property制定者BOOL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有问题使用 @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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆