Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c Switch语句不处理NS_枚举值_Objective C_Enums_Switch Statement - Fatal编程技术网

Objective c Switch语句不处理NS_枚举值

Objective c Switch语句不处理NS_枚举值,objective-c,enums,switch-statement,Objective C,Enums,Switch Statement,我在objective-c头中定义了一个枚举,如下所示: #import <UIKit/UIKit.h> #import <MapKit/MapKit.h> @interface CustomerAndProspectMapViewController : UIViewController<MKMapViewDelegate> typedef NS_ENUM(NSInteger, TypeEnum) { PROSPECT, CUSTOMER

我在objective-c头中定义了一个枚举,如下所示:

#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>
@interface CustomerAndProspectMapViewController : UIViewController<MKMapViewDelegate>
typedef NS_ENUM(NSInteger, TypeEnum)
{
    PROSPECT,
    CUSTOMER

};
@end
如您所见,枚举的两个选项在交换机中都有相应的路径。然而,出于某种原因,我得到了一个编译器警告说

枚举值“PROSPECT”和“CUSTOMER”未在中处理 开关


为了确保这一点,我在该方法中设置了一些断点。正如警告所示,它虽然掉了下来,但从未碰到过一个箱子。我还尝试重命名枚举值,以确保它们在某个地方没有冲突,仍然没有冲突。我完全被难住了。任何帮助都将不胜感激。

您忘记了关键字
案例

switch(accountType)
{
    case CUSTOMER:
    {
        [self performSegueWithIdentifier:@"customerDetails" sender:accountId];
        break;
    }

    case PROSPECT:
    {
        [self performSegueWithIdentifier:@"prospectDetails" sender:accountId];
        break;
    }

}


注意:您发布的代码创建了两个。

您忘记了关键字
case

switch(accountType)
{
    case CUSTOMER:
    {
        [self performSegueWithIdentifier:@"customerDetails" sender:accountId];
        break;
    }

    case PROSPECT:
    {
        [self performSegueWithIdentifier:@"prospectDetails" sender:accountId];
        break;
    }

}


注意:您发布的代码创建了两个。

有趣的是,您可能会错过。我已经为基于C的语言编程近30年了,我盯着这个问题看了几分钟,试图找出问题所在。当我向下滚动到你的答案,意识到它是如此简单时,我觉得自己很愚蠢facepalm我知道这一定是件傻事,但我没想到会有这么傻的事。有时只是为了显示第二双眼睛的价值。非常感谢。你错过了什么真有趣。我已经为基于C的语言编程近30年了,我盯着这个问题看了几分钟,试图找出问题所在。当我向下滚动到你的答案,意识到它是如此简单时,我觉得自己很愚蠢facepalm我知道这一定是件傻事,但我没想到会有这么傻的事。有时只是为了显示第二双眼睛的价值。非常感谢。