是否可以在属性上使用 !
(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 sameplayerGroup
value are automatched by Game Center. Setting theplayerGroup
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/