I\'ve been running into an issue using Swift 2\'s protocol extensions with default implementations. The basic gist is that I\'ve provided a default implementation of a proto
To simplify my lack thereof understanding what the word "Yet" means in a non-specific error. I figured out, that I can't seem write a function with arguments, in overriding extended function, and the compiler gives me an error like this, but if I write a simple function with no arguments, and make a custom implementation and call it with my overridden "simple function" It works:
import Foundation
import UIKit
extension UIViewController {
func slideInView(direction: Direction = Direction.LEFT, duration: CFTimeInterval = 0.5, closure:()->() ) {
let animation = CABasicAnimation(keyPath: "transform.translation.x")
animation.fromValue = self.view.bounds.width
animation.toValue = 0
animation.duration = 0.3
animation.fillMode = kCAFillModeForwards;
animation.removedOnCompletion = false
UIView.animateWithDuration(0.6, delay: 0.0, options: UIViewAnimationOptions.CurveEaseOut, animations: {
self.view!.layer.addAnimation(animation,forKey:nil);
}, completion: {(finished) -> () in
closure()
});
}
func slide() {
self.slideInView(.LEFT,duration: 0.66) {
print("Slide in Left Complete")
}
}
}
class OtherUIViewController: UIViewController {
override func slide() {
self.slideFromBottom(.BOTTOM,duration: 0.66) {
print("Slide in Bottom Complete")
}
}
func slideFromBottom(direction: Direction = Direction.BOTTOM, duration: CFTimeInterval = 0.5, closure:()->() ) {
let animation = CABasicAnimation(keyPath: "transform.translation.y")
animation.fromValue = self.view.bounds.height
animation.toValue = 0
animation.duration = 0.3
animation.fillMode = kCAFillModeForwards
animation.removedOnCompletion = false
UIView.animateWithDuration(0.6, delay: 0.0, options: UIViewAnimationOptions.CurveEaseOut, animations: {
self.view!.layer.addAnimation(animation,forKey:nil);
}, completion: {(finished) -> () in
closure()
});
}
}