I haven't used Swift so much, but based on Objective-C, there are a few things about Swift that PITA is cheating on.
In iOS programming, we have the animateWithDuration: method, which is part of the UIView.
So, I tried using Xcode autocomplete and started typing:
UIView.animateWith
Autocomplete shows:
UIView.animateWithDuration(duration: NSTimeInterval, animations: () -> Void)
Then I moved to the "duration" field, and then dialed the number:
UIView.animateWithDuration(0.5, animations: () -> Void)
Then I again moved to the animation block and pressed the enter button, as usual, in Objective-C, now Xcode shows:
UIView.animateWithDuration(0.5, animations: { () -> Void in code })
So, I last time put a tab to replace the "code" with my code:
UIView.animateWithDuration(0.5, animations: { () -> Void in self.customView?.transform = CGAffineTransformMakeTranslation(0.0, 0.0); })
What when Xcode then gives me an error:
Cannot call 'animateWithDuration' using argument list of type '(FloatLiteralConvertible, animation :() -> Void)'
I do not understand. What is the autocomplete code that Xcode generated for me, why does it give me an error?
I noticed if you make a simple statement like:
UIView.animateWithDuration(0.5, animations: { () -> Void in var num = 1 + 1; })
This does not give me any errors.
Any ideas anybody?