@property制定者BOOL

编程入门 行业动态 更新时间:2024-10-10 14:30:28
本文介绍了@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

本文发布于:2023-11-30 21:54:27,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1651592.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:制定者   property   BOOL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!