在从7.1和Swift 2.2升级到Xcode 7.3之前,代码运行良好。我也看到了使用typedef NS_ENUM(NSUInteger,MyStatus)的答案...但是,如果可能的话,我宁愿不更改现有的obj-c代码。
在obj-c头文件中定义:
typedef enum {
StatusPending,
StatusTimeout,
StatusSuccess,
StatusFail
} MyStatus;
Swift文件中的语句:
/* some code to retrieve the status */
switch (status) {
case .StatusSuccess:
/* do something */
/* other test cases omitted here */
default:
}
我尝试使用.rawValue,.value等,但是仍然出现错误:
在类型'MyStatus'中找不到枚举案例'StatusSuccess'
升级之前,所有程序工作正常,并尝试卸载/重新安装Xcode 7.3,产品->清洁,产品->清洁生成文件夹..,但未成功:-(
您不能在@interface和@end中声明“ typedef NS_ENUM(NSUInteger,EnumName){}”,xcode 7.2的解析不同于xcode 7.3。因此,只需将您的枚举声明移到@interface @end块之外,它应该可以正常工作,否则它被视为私有声明
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句