相关疑难解决方法(0)

升级到Xcode 7.3 swift 2.2后,从swift调用obj-c enum不起作用

在从7.1和swift 2.2升级到Xcode 7.3之前,代码运行良好.我也看到了使用typedef NS_ENUM(NSUInteger,MyStatus)的答案......但如果可能的话,我不想改变现有的obj-c代码.

在obj-c头文件中定义:

typedef enum {
    StatusPending,
    StatusTimeout,
    StatusSuccess,
    StatusFail
} MyStatus;
Run Code Online (Sandbox Code Playgroud)

Swift文件中的语句:

/* some code to retrieve the status */

switch (status) {

case .StatusSuccess:
 /* do something */

/* other test cases omitted here */

default:

}
Run Code Online (Sandbox Code Playgroud)

我尝试过使用.rawValue,.value等,但我仍然遇到错误:

在'MyStatus'类型中找不到枚举案例'StatusSuccess'

在升级之前一切正常,并尝试卸载/重新安装Xcode 7.3,Product-> Clean,Product-> Clean Build Folder ..但没有成功:-(

xcode enums typedef objective-c swift

9
推荐指数
1
解决办法
986
查看次数

标签 统计

enums ×1

objective-c ×1

swift ×1

typedef ×1

xcode ×1