Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swift 2/Xcode 7 beta - multiple bitmasks produce error

Tags:

ios

xcode7

swift2

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

like image 677
Adam Carter Avatar asked Dec 08 '22 03:12

Adam Carter


1 Answers

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]
like image 136
Adam Carter Avatar answered Dec 22 '22 13:12

Adam Carter