Gar*_*ice 7 enums objective-c swift
我在目标C文件中有以下枚举:
typedef NS_ENUM(NSInteger, countDirection){
countDirectionUp = 0,
countDirectionDown
};
Run Code Online (Sandbox Code Playgroud)
如何在快速视图控制器中使用它?我试过这个
label.countDirection = countDirection.countDirectionDown
Run Code Online (Sandbox Code Playgroud)
但是我收到了一个countDirection.Type does not have a member named countDirectionDown错误.
谢谢
gna*_*729 16
这些被翻译成
countDirection.Up
countDirection.Count
Run Code Online (Sandbox Code Playgroud)
Swift删除枚举值与枚举名称共有的尽可能多的字母.在您的情况下,使用名为countDirection的枚举和值countDirectionUp,将删除整个"countDirection".它不是必需的,因为你知道你正在使用哪个枚举,使你的代码相当短.