Skip to content
This repository has been archived by the owner on Nov 3, 2022. It is now read-only.

updates for compiling to Xcode 7.3 #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion Animation.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,9 @@
80C472FE19DDC6C2008274C0 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0600;
LastSwiftMigration = 0730;
LastSwiftUpdateCheck = 0730;
LastUpgradeCheck = 0730;
ORGANIZATIONNAME = IBM;
TargetAttributes = {
80C4730519DDC6C2008274C0 = {
Expand Down Expand Up @@ -447,6 +449,7 @@
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
COPY_PHASE_STRIP = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_OPTIMIZATION_LEVEL = 0;
Expand Down Expand Up @@ -527,6 +530,7 @@
IPHONEOS_DEPLOYMENT_TARGET = 8.1;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
OTHER_LDFLAGS = "-ObjC";
PRODUCT_BUNDLE_IDENTIFIER = "com.example.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = Animation;
PROVISIONING_PROFILE = "";
TARGETED_DEVICE_FAMILY = 1;
Expand All @@ -552,6 +556,7 @@
IPHONEOS_DEPLOYMENT_TARGET = 8.1;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
OTHER_LDFLAGS = "-ObjC";
PRODUCT_BUNDLE_IDENTIFIER = "com.example.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = Animation;
PROVISIONING_PROFILE = "";
TARGETED_DEVICE_FAMILY = 1;
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Animation/Dropdown/DropdownAppearTransitioning.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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())
Expand Down
4 changes: 2 additions & 2 deletions Animation/Dropdown/DropdownDismissTransitioning.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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())
Expand Down
14 changes: 7 additions & 7 deletions Animation/Dropdown/DropdownExampleViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions Animation/Dropdown/DropdownViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)"

Expand Down
12 changes: 6 additions & 6 deletions Animation/ExampleNobelViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should perform a do-try-catch block here, don't force try


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)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as other try block comment


nobelsByDiscipline = json2 as? NSArray

Expand Down Expand Up @@ -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 {

Expand Down
2 changes: 1 addition & 1 deletion Animation/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>com.example.$(PRODUCT_NAME:rfc1034identifier)</string>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
Expand Down
20 changes: 10 additions & 10 deletions Animation/LayoutConstraintAnimator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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]
}

Expand All @@ -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]
}
}
Expand Down
2 changes: 1 addition & 1 deletion Animation/MainNavigationViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
6 changes: 3 additions & 3 deletions Animation/MainViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,12 @@ class MainViewController: UIViewController, UIScrollViewDelegate, UITableViewDat
// 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
self.navigationController?.pushViewController(view, animated: true)
var view = nav.viewControllers.first
self.navigationController?.pushViewController(view!, animated: true)
} else {
self.navigationController?.pushViewController(vc, animated: true)
}
Expand Down
4 changes: 2 additions & 2 deletions Animation/Modal/ModalAppearTransitioning.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ This licensed material is licensed under the Apache 2.0 license. http://www.apac

class ModalAppearTransitioning: NSObject, UIViewControllerAnimatedTransitioning {

func transitionDuration(transitionContext: UIViewControllerContextTransitioning) -> NSTimeInterval {
func transitionDuration(transitionContext: UIViewControllerContextTransitioning?) -> NSTimeInterval {
return 0.8
}

Expand All @@ -19,7 +19,7 @@ class ModalAppearTransitioning: NSObject, UIViewControllerAnimatedTransitioning
let container = transitionContext.containerView()
let duration = transitionDuration(transitionContext)

container.addSubview(to.view)
container!.addSubview(to.view)

to.show() {
transitionContext.completeTransition(!transitionContext.transitionWasCancelled())
Expand Down
4 changes: 2 additions & 2 deletions Animation/Modal/ModalDismissTransitioning.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ This licensed material is licensed under the Apache 2.0 license. http://www.apac

class ModalDismissTransitioning: NSObject, UIViewControllerAnimatedTransitioning {

func transitionDuration(transitionContext: UIViewControllerContextTransitioning) -> NSTimeInterval {
func transitionDuration(transitionContext: UIViewControllerContextTransitioning?) -> NSTimeInterval {
return 0.8
}

Expand All @@ -20,7 +20,7 @@ class ModalDismissTransitioning: NSObject, UIViewControllerAnimatedTransitioning
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())
Expand Down
2 changes: 1 addition & 1 deletion Animation/Modal/ModalExampleViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class ModalExampleViewController: ExampleNobelViewController {
// MARK: - Lifecycle

override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
var modalVC = segue.destinationViewController as! ModalViewController
let modalVC = segue.destinationViewController as! ModalViewController
modalVC.modalPresentationStyle = .Custom
modalVC.transitioningDelegate = modalTransitioningDelegate

Expand Down
10 changes: 5 additions & 5 deletions Animation/Modal/ModalViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class ModalViewController: UIViewController, UITableViewDelegate {
loader.animationImages = [UIImage]()

for var index = 100; index < 147; index++ {
var frameName = String(format: "Loader_00%03d", index)
let frameName = String(format: "Loader_00%03d", index)
loader.animationImages?.append(UIImage(named:frameName)!)
}

Expand Down Expand Up @@ -136,16 +136,16 @@ class ModalViewController: UIViewController, UITableViewDelegate {
// display PDF
// first string value is pdf file name
var pdfLoc = NSURL(fileURLWithPath:NSBundle.mainBundle().pathForResource("Bee", ofType:"pdf")!)
var request = NSURLRequest(URL: pdfLoc!);
var request = NSURLRequest(URL: pdfLoc);
self.pdfView.loadRequest(request);
self.pdfView.alpha = 0
self.pdfView.transform = CGAffineTransformMakeScale(0.75, 0.75)

// show PDF
UIView.animateWithDuration(animationDuration, delay: 1.5, options: nil, animations: { () -> Void in
UIView.animateWithDuration(animationDuration, delay: 1.5, options: [], animations: { () -> Void in
self.loader.alpha = 0 // fade out loader
}, completion: { finished in
UIView.animateWithDuration(0.25, delay: 0, options: nil, animations: { () -> Void in
UIView.animateWithDuration(0.25, delay: 0, options: [], animations: { () -> Void in
// fade in PDF
self.loaderBG.alpha = 0
self.pdfView.alpha = 1
Expand All @@ -162,7 +162,7 @@ class ModalViewController: UIViewController, UITableViewDelegate {

func hide(completion: () -> Void ) {

var animationDuration = Double(self.animationMultiplier) * 1 / 4.0;
let animationDuration = Double(self.animationMultiplier) * 1 / 4.0;

self.view.layoutIfNeeded()

Expand Down
14 changes: 7 additions & 7 deletions Animation/Search/SearchExampleViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class SearchExampleViewController: ExampleNobelViewController, UITextFieldDelega

// grabs the animation frames from the bundle
for var index = 100; index < 147; index++ {
var frameName = String(format: "Loader_00%03d", index)
let frameName = String(format: "Loader_00%03d", index)
loader.animationImages?.append(UIImage(named:frameName)!)
}

Expand Down Expand Up @@ -120,7 +120,7 @@ class SearchExampleViewController: ExampleNobelViewController, UITextFieldDelega
/**
* Performs all of the animations necessary to display the search results
*
* :param: results The string to display as the search result
* - parameter results: The string to display as the search result
*/
func showResults(results: String) {
resultsLabel.text = results
Expand Down Expand Up @@ -179,7 +179,7 @@ class SearchExampleViewController: ExampleNobelViewController, UITextFieldDelega
let animationDelay: NSTimeInterval = 0

UIView.animateWithDuration(animationDuration, delay: animationDelay,
options: nil, animations: { () -> Void in
options: [], animations: { () -> Void in
self.itemsView.alpha = 1.0
self.tableView.alpha = 1.0
}, completion: nil)
Expand Down Expand Up @@ -243,21 +243,21 @@ class SearchExampleViewController: ExampleNobelViewController, UITextFieldDelega
// MARK: - Text Field

func textChanged() -> Void {
self.xButton.hidden = count(self.searchField.text) == 0
self.xButton.hidden = self.searchField.text!.characters.count == 0
}

func textFieldDidBeginEditing(textField: UITextField) {
self.collapseHeader()

self.xButton.hidden = count(textField.text) == 0
self.xButton.hidden = textField.text!.characters.count == 0
}

func textFieldShouldReturn(textField: UITextField) -> Bool {
if count(textField.text) < 2 {
if textField.text!.characters.count < 2 {
return false
}

search(textField.text)
search(textField.text!)

return true
}
Expand Down
Loading