Swift 2/Xcode 7 beta - 多个位掩码产生错误

Posted

技术标签:

【中文标题】Swift 2/Xcode 7 beta - 多个位掩码产生错误【英文标题】:Swift 2/Xcode 7 beta - multiple bitmasks produce error 【发布时间】:2015-06-14 22:03:56 【问题描述】:

我正在创建一个 UIView 动画:

UIView.animateWithDuration(0.1,
    delay: 0,
    options: (.AllowUserInteraction | .Repeat | .Autoreverse),
    animations:
         () -> Void in

            // Animate

    ,
    completion: nil)

但是编译器说“找不到成员“Autoreverse””,或者最后的任何位掩码,除非有一个选项。 Swift 2 中的语法有变化吗?我看不到 Swift 文档中的任何内容,也记不起 WWDC 演示文稿中的任何内容。

或者它可能只是一个错误?

提前致谢

【问题讨论】:

【参考方案1】:

在这里找到答案:

Swift 2.0 - Binary Operator "|" cannot be applied to two UIUserNotificationType operands

“在 Swift 2 中,语法已经更新..”

简而言之,而不是

.Type | .Another | .Third

使用

[.Type, .Another, .Third]

【讨论】:

以上是关于Swift 2/Xcode 7 beta - 多个位掩码产生错误的主要内容,如果未能解决你的问题,请参考以下文章