gpt4 book ai didi

iphone - objective-c 开关语句中的OR运算符

转载 作者:行者123 更新时间:2023-12-01 17:15:50 25 4
gpt4 key购买 nike

我想知道是否有可能在ta开关语句中使用(||)“or”或(&&)“and”运算符。

这就是我的想法。

switch (orientation) {
case UIDeviceOrientationPortrait:
{
case (UIDeviceOrientationLandscapeLeft || UIDeviceOrientationLandscapeRight):
}
break;
//...

如果有人可以帮助我,我将非常感激:)

最佳答案

&&是不可能的,但是可以实现类似于||的东西。通过不间断地处理多个案件:

switch (orientation)
{
case UIDeviceOrientationPortrait:
// ...
break;

case UIDeviceOrientationLandscapeLeft:
case UIDeviceOrientationLandscapeRight:
// ...
break;
}

您当然也可以在case块中使用 orientation(即进一步评估)

关于iphone - objective-c 开关语句中的OR运算符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11043925/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com