简体   繁体   中英

Swift 2/Xcode 7 beta - multiple bitmasks produce error

Im creating a UIView animation:

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

            // Animate

    },
    completion: nil)

But the compiler says “Could not find member “Autoreverse””, or whichever bit mask is on the end, unless there is one option. Has the syntax changed in Swift 2? I can't see anything in the Swift docs nor do I remember anything in the WWDC presentations.

Or could it possibly just be a bug?

Thanks in advance

Answer found here:

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

“In Swift 2 the syntax has been updated..”

To cut it short, instead of

.Type | .Another | .Third

Use

[.Type, .Another, .Third]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM