diff --git a/.gitignore b/.gitignore index 48fa083..4737552 100644 --- a/.gitignore +++ b/.gitignore @@ -31,3 +31,4 @@ Pods/ Carthage/Checkouts Carthage/Build +contents.xcworkspacedata diff --git a/Animation.xcodeproj/project.pbxproj b/Animation.xcodeproj/project.pbxproj index 6099f42..cf3ca94 100644 --- a/Animation.xcodeproj/project.pbxproj +++ b/Animation.xcodeproj/project.pbxproj @@ -301,6 +301,8 @@ 80C472FE19DDC6C2008274C0 /* Project object */ = { isa = PBXProject; attributes = { + LastSwiftMigration = 0700; + LastSwiftUpdateCheck = 0700; LastUpgradeCheck = 0600; ORGANIZATIONNAME = IBM; TargetAttributes = { diff --git a/Animation/Base.lproj/Main.storyboard b/Animation/Base.lproj/Main.storyboard index 62baa94..c4cb32f 100644 --- a/Animation/Base.lproj/Main.storyboard +++ b/Animation/Base.lproj/Main.storyboard @@ -1,7 +1,8 @@ - + - + + diff --git a/Animation/Dropdown/DropdownAppearTransitioning.swift b/Animation/Dropdown/DropdownAppearTransitioning.swift index 1492dd8..cceffb2 100644 --- a/Animation/Dropdown/DropdownAppearTransitioning.swift +++ b/Animation/Dropdown/DropdownAppearTransitioning.swift @@ -8,7 +8,7 @@ This licensed material is licensed under the Apache 2.0 license. http://www.apac class DropdownAppearTransitioning: NSObject, UIViewControllerAnimatedTransitioning { - func transitionDuration(transitionContext: UIViewControllerContextTransitioning) -> NSTimeInterval { + func transitionDuration(transitionContext: UIViewControllerContextTransitioning?) -> NSTimeInterval { return 0.8 } @@ -19,7 +19,7 @@ class DropdownAppearTransitioning: NSObject, UIViewControllerAnimatedTransitioni let container = transitionContext.containerView() let duration = transitionDuration(transitionContext) - container.addSubview(to.view) + container!.addSubview(to.view) to.show() { transitionContext.completeTransition(!transitionContext.transitionWasCancelled()) diff --git a/Animation/Dropdown/DropdownDismissTransitioning.swift b/Animation/Dropdown/DropdownDismissTransitioning.swift index 2726792..804dc93 100644 --- a/Animation/Dropdown/DropdownDismissTransitioning.swift +++ b/Animation/Dropdown/DropdownDismissTransitioning.swift @@ -8,7 +8,7 @@ This licensed material is licensed under the Apache 2.0 license. http://www.apac class DropdownDismissTransitioning: NSObject, UIViewControllerAnimatedTransitioning { - func transitionDuration(transitionContext: UIViewControllerContextTransitioning) -> NSTimeInterval { + func transitionDuration(transitionContext: UIViewControllerContextTransitioning?) -> NSTimeInterval { return 0.8 } @@ -20,7 +20,7 @@ class DropdownDismissTransitioning: NSObject, UIViewControllerAnimatedTransition let container = transitionContext.containerView() let duration = transitionDuration(transitionContext) - container.insertSubview(to.view, atIndex: 0) + container!.insertSubview(to.view, atIndex: 0) from.hide() { transitionContext.completeTransition(!transitionContext.transitionWasCancelled()) diff --git a/Animation/Dropdown/DropdownExampleViewController.swift b/Animation/Dropdown/DropdownExampleViewController.swift index 4354e56..c0ec3d2 100644 --- a/Animation/Dropdown/DropdownExampleViewController.swift +++ b/Animation/Dropdown/DropdownExampleViewController.swift @@ -44,7 +44,7 @@ class DropdownExampleViewController: ExampleNobelViewController, DropDownViewCon UIImage(named: "circle_x_06")!, UIImage(named: "circle_x_07")! ]; - var reversedAnimationImages: [UIImage] { get { return reverse(animationImages) } } + var reversedAnimationImages: [UIImage] { get { return Array(animationImages.reverse()) } } var hiddenStatusBar:Bool = false { didSet { @@ -89,16 +89,16 @@ class DropdownExampleViewController: ExampleNobelViewController, DropDownViewCon func show(completion: () -> Void) { dropdownButtonImage.animationImages = self.animationImages; - dropdownButtonImage.image = dropdownButtonImage.animationImages?.last as? UIImage + dropdownButtonImage.image = dropdownButtonImage.animationImages?.last dropdownButtonImage.startAnimating() let delay = dropdownButtonImage.animationDuration * Double(NSEC_PER_SEC) - var time = dispatch_time(DISPATCH_TIME_NOW, Int64(delay)) + let time = dispatch_time(DISPATCH_TIME_NOW, Int64(delay)) dispatch_after(time, dispatch_get_main_queue(), { () -> Void in self.dropdownButtonImage.stopAnimating() }) - var animationDuration = Double(self.animationMultiplier) * 1 / 2.5; + let animationDuration = Double(self.animationMultiplier) * 1 / 2.5; UIView.animateWithDuration(animationDuration, animations: { () -> Void in self.backgroundView.alpha = 1 @@ -108,16 +108,16 @@ class DropdownExampleViewController: ExampleNobelViewController, DropDownViewCon func hide(completion: () -> Void ) { dropdownButtonImage.animationImages = self.reversedAnimationImages - dropdownButtonImage.image = dropdownButtonImage.animationImages?.last as? UIImage + dropdownButtonImage.image = dropdownButtonImage.animationImages?.last dropdownButtonImage.startAnimating() let delay = dropdownButtonImage.animationDuration * Double(NSEC_PER_SEC) - var time = dispatch_time(DISPATCH_TIME_NOW, Int64(delay)) + let time = dispatch_time(DISPATCH_TIME_NOW, Int64(delay)) dispatch_after(time, dispatch_get_main_queue(), { () -> Void in self.dropdownButtonImage.stopAnimating() }) - var animationDuration = Double(self.animationMultiplier) * 1 / 2.5; + let animationDuration = Double(self.animationMultiplier) * 1 / 2.5; UIView.animateWithDuration(animationDuration, animations: { () -> Void in self.backgroundView.alpha = 0 diff --git a/Animation/Dropdown/DropdownViewController.swift b/Animation/Dropdown/DropdownViewController.swift index 2d94173..6972098 100644 --- a/Animation/Dropdown/DropdownViewController.swift +++ b/Animation/Dropdown/DropdownViewController.swift @@ -57,7 +57,7 @@ class DropdownViewController: UIViewController, UITableViewDataSource, UITableVi ]; var delegate:DropDownViewControllerDelegate? - var reversedAnimationImages: [UIImage] { get { return reverse(animationImages) } } + var reversedAnimationImages: [UIImage] { get { return Array(animationImages.reverse()) } } var tableHeight: CGFloat { get { return CGFloat(cellHeight * numberOfCells) } } var dropdownPressed: ((index: Int) -> Void)? var isOpen = false @@ -126,7 +126,7 @@ class DropdownViewController: UIViewController, UITableViewDataSource, UITableVi func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { - var cell = tableView.dequeueReusableCellWithIdentifier("DropdownOptionCell") as! DropdownOptionCell + let cell = tableView.dequeueReusableCellWithIdentifier("DropdownOptionCell") as! DropdownOptionCell cell.label.text = "Option \(indexPath.row + 1)" diff --git a/Animation/ExampleNobelViewController.swift b/Animation/ExampleNobelViewController.swift index 16e2463..34da56e 100644 --- a/Animation/ExampleNobelViewController.swift +++ b/Animation/ExampleNobelViewController.swift @@ -39,14 +39,14 @@ class ExampleNobelViewController: UIViewController, UITableViewDataSource, UITab var error:NSError? let path1 = bundle.pathForResource("nobels_alphabetically", ofType: "json") - var data1:NSData = NSData(contentsOfFile: path1!)! - let json1:AnyObject = NSJSONSerialization.JSONObjectWithData(data1, options: NSJSONReadingOptions.AllowFragments, error:&error)! + let data1:NSData = NSData(contentsOfFile: path1!)! + let json1:AnyObject = try! NSJSONSerialization.JSONObjectWithData(data1, options: NSJSONReadingOptions.AllowFragments) nobelsAlphabetically = json1 as? NSArray let path2 = bundle.pathForResource("nobels_by_discipline", ofType: "json") - var data2:NSData = NSData(contentsOfFile: path2!)! - let json2:AnyObject = NSJSONSerialization.JSONObjectWithData(data2, options: NSJSONReadingOptions.AllowFragments, error:&error)! + let data2:NSData = NSData(contentsOfFile: path2!)! + let json2:AnyObject = try! NSJSONSerialization.JSONObjectWithData(data2, options: NSJSONReadingOptions.AllowFragments) nobelsByDiscipline = json2 as? NSArray @@ -79,11 +79,11 @@ class ExampleNobelViewController: UIViewController, UITableViewDataSource, UITab let array = section["Data"] as? NSArray - var nobel_dict = NSMutableDictionary() + let nobel_dict = NSMutableDictionary() nobel_dict["Section"] = section["Section"] - var nobel_array = NSMutableArray() + let nobel_array = NSMutableArray() if let array = array { diff --git a/Animation/LayoutConstraintAnimator.swift b/Animation/LayoutConstraintAnimator.swift index 1c06e3b..89937e6 100644 --- a/Animation/LayoutConstraintAnimator.swift +++ b/Animation/LayoutConstraintAnimator.swift @@ -45,12 +45,12 @@ class LayoutConstraintAnimator: NSObject { The constructor for the animation. Once the animation is created, it is not able to be modified or stopped. - :param: constraints The set of constraints to be animated - :param: delay The delay, in seconds, before beginning the animation - :param: duration The duration, in seconds, of the animation to be performed - :param: toConstants The values of the constants to be set on each of the constraints - :param: easing The easing algorithm to be used when calculating the target's values - :param: completion The block to be performed on completion of the animation + - parameter constraints: The set of constraints to be animated + - parameter delay: The delay, in seconds, before beginning the animation + - parameter duration: The duration, in seconds, of the animation to be performed + - parameter toConstants: The values of the constants to be set on each of the constraints + - parameter easing: The easing algorithm to be used when calculating the target's values + - parameter completion: The block to be performed on completion of the animation */ required init(constraints: [NSLayoutConstraint], delay:NSTimeInterval, duration:NSTimeInterval, toConstants:[CGFloat], easing: LayoutConstraintEasing, @@ -87,11 +87,11 @@ class LayoutConstraintAnimator: NSObject { } } - var time = CGFloat((CACurrentMediaTime() - startTime) / duration) + let time = CGFloat((CACurrentMediaTime() - startTime) / duration) // check to see if the animation has completed if time >= 1 { - for (index, constraint) in enumerate(constraints) { + for (index, constraint) in constraints.enumerate() { constraint.constant = toConstants[index] } @@ -106,9 +106,9 @@ class LayoutConstraintAnimator: NSObject { } // process the animation - var t = easing.valueFor(CGFloat(time)) + let t = easing.valueFor(CGFloat(time)) - for (index, constraint) in enumerate(constraints) { + for (index, constraint) in constraints.enumerate() { constraint.constant = (1 - t) * fromConstants[index] + t * toConstants[index] } } diff --git a/Animation/MainNavigationViewController.swift b/Animation/MainNavigationViewController.swift index 1aa4446..a5bd152 100644 --- a/Animation/MainNavigationViewController.swift +++ b/Animation/MainNavigationViewController.swift @@ -20,7 +20,7 @@ class MainNavigationViewController: UINavigationController { // Create a long press recognizer that requires two fingers and reverts the navigation back to the // main menu. - var longPressRecognizer = UILongPressGestureRecognizer(target: self, action: Selector("longPress:")) + let longPressRecognizer = UILongPressGestureRecognizer(target: self, action: Selector("longPress:")) longPressRecognizer.numberOfTouchesRequired = 2 view.addGestureRecognizer(longPressRecognizer) } diff --git a/Animation/MainViewController.swift b/Animation/MainViewController.swift index 9cbe8d1..82e1110 100644 --- a/Animation/MainViewController.swift +++ b/Animation/MainViewController.swift @@ -110,15 +110,18 @@ class MainViewController: UIViewController, UIScrollViewDelegate, UITableViewDat // The view controller is pushed in a different way depending if it's inside a // navigation controller. func showView(storyboard: String, viewControllerID: String) { + let sb = UIStoryboard(name: storyboard, bundle: nil) - let vc = sb.instantiateViewControllerWithIdentifier(viewControllerID) as! UIViewController + let vc = sb.instantiateViewControllerWithIdentifier(viewControllerID) - if vc is UINavigationController { - var nav = vc as! UINavigationController - var view = nav.viewControllers.first as! UIViewController + if let nav = vc as? UINavigationController, let view = nav.viewControllers.first { + self.navigationController?.pushViewController(view, animated: true) + } else { + self.navigationController?.pushViewController(vc, animated: true) + } } diff --git a/Animation/Modal/Modal.storyboard b/Animation/Modal/Modal.storyboard index 4038686..514372a 100644 --- a/Animation/Modal/Modal.storyboard +++ b/Animation/Modal/Modal.storyboard @@ -1,7 +1,8 @@ - + - + + @@ -101,7 +102,7 @@ -