【发布时间】:2015-08-02 02:31:10
【问题描述】:
我在 Objective-c 标头中定义了一个枚举,如下所示:
#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>
@interface CustomerAndProspectMapViewController : UIViewController<MKMapViewDelegate>
typedef NS_ENUM(NSInteger, TypeEnum)
{
PROSPECT,
CUSTOMER
};
@end
然后在实现中我有一个函数,它以 TypeEnum 作为参数并使用开关来运行一些条件代码:
-(void) handleTestNavigation:(NSString *)accountId :(TypeEnum)accountType
{
switch(accountType)
{
CUSTOMER:
{
[self performSegueWithIdentifier:@"customerDetails" sender:accountId];
break;
}
PROSPECT:
{
[self performSegueWithIdentifier:@"prospectDetails" sender:accountId];
break;
}
}
}
如您所见,枚举的两个选项在开关中都有对应的路径。然而由于某种原因,我收到编译器警告说
枚举值 'PROSPECT' 和 'CUSTOMER' 未在 切换
为了确保,我在该方法中设置了一些断点。正如警告所表明的那样,它虽然没有击中一个案例,但它还是跌落了。我还尝试重命名枚举值,以确保它们在某处没有冲突并且仍然没有。我完全被难住了。任何帮助将不胜感激。
【问题讨论】:
标签: objective-c enums switch-statement