Compiler errors Swift";运算符'的使用不明确=='&引用;

Compiler errors Swift";运算符'的使用不明确=='&引用;,compiler-errors,operator-overloading,swift,Compiler Errors,Operator Overloading,Swift,我试图将UIUserNotificationType的一个实例(即rawoptionstart)与某个值进行比较: var types: UIUserNotificationType = ... if types == UIUserNotificationType.None { // <-- Error here ... } 试试这个,我试着看看你的有什么问题(这很有效): 这也行得通,但它看起来确实像是一个bug,而原版没有: if types.value == UIUser

我试图将
UIUserNotificationType
的一个实例(即
rawoptionstart
)与某个值进行比较:

var types: UIUserNotificationType = ...
if types == UIUserNotificationType.None { // <-- Error here
     ...
}

试试这个,我试着看看你的有什么问题(这很有效):

这也行得通,但它看起来确实像是一个bug,而原版没有:

if types.value == UIUserNotificationType.None.value {
        println("None, too")
}

关于
types.value==UIUserNotificationType.None.value呢
UIUserNotificationType是相等的,这对我来说还是一个bug,我还不熟悉。因此,我将首先把它作为一个建议放在这里。我认为如果让someType=types.None{//do someType}@markhunte,您应该使用可选绑定
,不过它不起作用<代码>类型显然不是可选的。如果
rawOptiStart
有多个值,这将如何表现?i、 e.
let types=UIUserNotificationType.Badge | Sound
    var types = UIUserNotificationType.Sound | UIUserNotificationType.Badge

    switch types {
        case UIUserNotificationType.None:
            println("None")
        case UIUserNotificationType.Badge | UIUserNotificationType.Sound :
            println("Badge & Sound") // This will print
        case UIUserNotificationType.Badge:
            println("Badge")
        case UIUserNotificationType.Alert:
            println("Alert")
        case UIUserNotificationType.Sound:
            println("Sound")
        default:
            println("default")
    }
if types.value == UIUserNotificationType.None.value {
        println("None, too")
}