Ios 枚举案例“country”不是“RegisterViewController.options”类型的成员,为什么会这样?

Ios 枚举案例“country”不是“RegisterViewController.options”类型的成员,为什么会这样?,ios,swift,uitableview,Ios,Swift,Uitableview,我想根据单击的按钮更改tableview的数据源数组。 我使用枚举方法来识别或标记我单击的按钮 但在代码中,它显示了如下错误: 枚举案例“country”不是“RegisterViewController.options”类型的成员 我想不出来 选项是包含3个案例的枚举 //enum declaration enum options { case dawat case country case nationality } var lastSelection:opti

我想根据单击的按钮更改tableview的数据源数组。 我使用枚举方法来识别或标记我单击的按钮

但在代码中,它显示了如下错误:

枚举案例“country”不是“RegisterViewController.options”类型的成员

我想不出来

选项是包含3个案例的枚举

//enum declaration

enum options {
    case dawat
    case country
    case nationality
}

var lastSelection:options?
嘿,看看这个答案:

enum  options  {
    case dawat
    case country
    case nationality
    case none

}

var lastSelection = options.none

在使用可选属性之前,请先将其展开

if let last = lastSelection {
    switch last { 
        case options.country:
            signUser.unfilteredArray = signUser.countries
        //and so on...                
    }
} else {
    //?
}
或将默认案例添加到枚举中

enum options {
    case dawat
    case country
    case nationality
    case notSet
}

var lastSelection = options.notSet
然后在开关中使用它

switch lastSelection { 
    //other case...
    case options.notSet:
        //?
    }
}

能否添加enum RegisterViewController的定义。选项?需要更多说明才能理解您的问题,请在问题中添加enum声明的代码?好的,请稍候阅读错误消息。“RegisterViewController.options”中的问号表示lastSelection是可选的,需要取消包装。@JaseelCalicut:然后请显示更新的代码和确切的错误消息。如果答案解释了问题和解决方案,而不是只转储一些代码,则会更有帮助。确定,我会通过澄清来改进这个答案。如果我添加了更多的代码..你会因为代码太多而责怪我//请不要为你的帮助找理由伙计我已经做了一个演示,它对我有用请参考屏幕截图问题依然存在
switch lastSelection { 
    //other case...
    case options.notSet:
        //?
    }
}