Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS Core Animation - Rotation & Position

Why is this error in the Stickies code?

I was looking at the Swift code in the Stickies app and I noticed this error in mute action:

Cannot invoke 'animationWithDuration' with an argument of list type '(Double, delay: Double, options: NSArray, animations: () -> Void, completion: nil)'
 @IBAction func mute() {
        UIView.animateWithDuration(1.0, delay: 0.0, options: [], animations:  <=== error
            { () -> Void in
            self.alpha = 0.25
        }, completion: nil)
    }

Pasan Premaratne , or Gabe Nadel , can you take a look?

2 Answers

UIView.animateWithDuration(1.0, delay: 0.0, options: UIViewAnimationOptions.CurveLinear, animations:
            { () -> Void in

            self.alpha = 0.25

}, completion: nil)

You are using an array for options when you need to use UIViewAnimationOptions

I downloaded the project files from the Stickies app in this workshop, in Objective-C the options are set to '0', so I guess that means there are no options. So how would you do that in Swift? is that what UIViewAnimationOptions.CurveLinear does?

Yes essentially UIViewAnimationOptions.CurveLinear is a fancy way of saying that that there are no options

Okay, that makes sense.