【发布时间】:2015-11-07 08:09:02
【问题描述】:
我有一个枚举定义如下,
class Question: NSObject {
enum Type:String {
case Text = "TEXT"
case Image = "IMAGE"
}
/**!!!Here I can access it like this!!!*/
var type = Type.Text
}
但是,在另一个类中,
class MyViewController: UIViewController {
/**!!!This doesn't work!!!*/
var type = Question.Type.Text
}
是不是我做错了什么?
谢谢
【问题讨论】:
-
我不知道具体原因,但您不能将枚举命名为
Type。将其更改为其他内容,它将起作用。 -
看起来你重新实现了现有类型
Type,例如尝试使用enum Type2:String来测试它 -
@Rog 谢谢,终于明白了。苹果太可笑了。
标签: ios swift cocoa-touch enums