cra*_*man 9 xcode enums typedef objective-c swift
在从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 ..但没有成功:-(
Kun*_*nna 14
你不能在@interface和@end中声明"typedef NS_ENUM(NSUInteger,EnumName){}",xcode 7.2的解析与xcode 7.3不同.所以,只需将你的枚举声明移到@interface @end块之外,它应该可以正常工作,否则它被视为私有声明
| 归档时间: |
|
| 查看次数: |
986 次 |
| 最近记录: |