ios - 我可以使用 !属性(property)的运算符(operator)?

标签 ios objective-c properties operators not-operator

是否可以在属性上使用 !(not 或 bang)运算符?我想要这样做的原因是因为我可能会找到一个与我想要它做的完全相反的属性。这是我的想法的一个例子。

GKMatchRequest *request = [[GKMatchRequest alloc] init];
request.minPlayers = 2;
request.maxPlayers = 2;
request.!playerGroup = MyMap_Forest | MyRulesCaptureTheFlag;

我从 Apple Docs 得到这个例子并对其进行修改。

这是文档所说的:

If your game sets the playerGroup property, only players whose requests share the same playerGroup value are automatched by Game Center. Setting the playerGroup property to 0 allows the player to be matched into any waiting match. Set the playerGroup property to a nonzero number to match the player only with players whose match request shares the same player group number.

最佳答案

你似乎想做的事是不可能的。 playerGroup 属性只有两种可能的语义:如果它是 0,那么它匹配任何东西;如果它是任何非零值,则它只匹配具有相同值的请求。

没有办法实现“匹配任何除了这个值”。这与语言或语法无关。这完全取决于 Apple 如何定义 playerGroup 属性。其语义在实现中,既在框架中又在服务器端。希望某些假设的语言特性可以在这些代码段中引发不同的行为是不明智的。

关于ios - 我可以使用 !属性(property)的运算符(operator)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33263610/

相关文章:

ios - 从框架访问AppDelegate?

ios - UITableViewCell 不显示文字

ios - 从一个 View Controller 导航到另一个 View Controller 时如何更改变量的值?

objective-c - CIFilter - 无法更改名称

iOS 导航 View 背景图像 UIViewContentModeScaleAspectFill 不工作

java - IntelliJ 中的属性文件问题(添加到类路径)JSP(空指针 ex)

javascript - JS 中是否有相当于 Python 的 .get() 的功能?

c# - 动态访问属性的最佳实践?

iphone - XCode 3.2.4 升级后做逻辑测试的问题

ios - 如何在 UICollectionView 中居中对齐项目?