Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swift 3.0 Support #72

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
6 changes: 6 additions & 0 deletions Child Labor.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3178,9 +3178,11 @@
83800C761AA4D40300DD47EB = {
CreatedOnToolsVersion = 6.1.1;
DevelopmentTeam = FRPCGFXS7Q;
LastSwiftMigration = 0810;
};
83800C8B1AA4D40300DD47EB = {
CreatedOnToolsVersion = 6.1.1;
LastSwiftMigration = 0810;
TestTargetID = 83800C761AA4D40300DD47EB;
};
};
Expand Down Expand Up @@ -4347,6 +4349,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = "";
SWIFT_OBJC_BRIDGING_HEADER = "Child Labor-Bridging-Header.h";
SWIFT_VERSION = 3.0;
TARGETED_DEVICE_FAMILY = 1;
};
name = Debug;
Expand All @@ -4369,6 +4372,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = "";
SWIFT_OBJC_BRIDGING_HEADER = "Child Labor-Bridging-Header.h";
SWIFT_VERSION = 3.0;
TARGETED_DEVICE_FAMILY = 1;
};
name = Release;
Expand All @@ -4386,6 +4390,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "gov.dol.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Child Labor.app/Child Labor";
};
name = Debug;
Expand All @@ -4399,6 +4404,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "gov.dol.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Child Labor.app/Child Labor";
};
name = Release;
Expand Down
24 changes: 12 additions & 12 deletions Child Labor/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,52 +14,52 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?


func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.

// Init Google Analytics
GAI.sharedInstance().trackUncaughtExceptions = true
GAI.sharedInstance().dispatchInterval = 20
// GAI.sharedInstance().logger.logLevel = GAILogLevel.Verbose
GAI.sharedInstance().trackerWithTrackingId("UA-61504244-3").set(kGAIAnonymizeIp, value: "1")
GAI.sharedInstance().tracker(withTrackingId: "UA-61504244-3").set(kGAIAnonymizeIp, value: "1")

return true
}

func applicationWillResignActive(application: UIApplication) {
func applicationWillResignActive(_ application: UIApplication) {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

func applicationDidEnterBackground(application: UIApplication) {
func applicationDidEnterBackground(_ application: UIApplication) {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

func applicationWillEnterForeground(application: UIApplication) {
func applicationWillEnterForeground(_ application: UIApplication) {
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

func applicationDidBecomeActive(application: UIApplication) {
func applicationDidBecomeActive(_ application: UIApplication) {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

func applicationWillTerminate(application: UIApplication) {
func applicationWillTerminate(_ application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

@available(iOS 9.0, *)
func application(application: UIApplication, performActionForShortcutItem shortcutItem: UIApplicationShortcutItem, completionHandler: (Bool) -> Void) {
func application(_ application: UIApplication, performActionFor shortcutItem: UIApplicationShortcutItem, completionHandler: @escaping (Bool) -> Void) {
let navigationController = self.window?.rootViewController as! UINavigationController
let mainViewController = navigationController.viewControllers[0] as! IndexViewController

navigationController.popToRootViewControllerAnimated(false)
navigationController.popToRootViewController(animated: false)
if shortcutItem.type == "OpenCountries" {
mainViewController.performSegueWithIdentifier("countriesSelectedFromIndex", sender: self)
mainViewController.performSegue(withIdentifier: "countriesSelectedFromIndex", sender: self)
} else if shortcutItem.type == "OpenGoods" {
mainViewController.performSegueWithIdentifier("goodsSelectedFromIndex", sender: self)
mainViewController.performSegue(withIdentifier: "goodsSelectedFromIndex", sender: self)
} else if shortcutItem.type == "OpenExploitationTypes" {
mainViewController.performSegueWithIdentifier("exploitationSelectedFromIndex", sender: self)
mainViewController.performSegue(withIdentifier: "exploitationSelectedFromIndex", sender: self)
}
}

Expand Down
2 changes: 1 addition & 1 deletion Child Labor/AutoTableViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class AutoTableViewController: UITableViewController {
// Dispose of any resources that can be recreated.
}

override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return UITableViewAutomaticDimension
}

Expand Down
26 changes: 13 additions & 13 deletions Child Labor/ConventionsTableViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ class ConventionsTableViewController: UITableViewController {

// Record GA view
let tracker = GAI.sharedInstance().defaultTracker
tracker.set(kGAIScreenName, value: "Conventions Screen")
tracker.send(GAIDictionaryBuilder.createAppView().build() as [NSObject : AnyObject])
tracker?.set(kGAIScreenName, value: "Conventions Screen")
tracker?.send(GAIDictionaryBuilder.createAppView().build() as NSDictionary? as? [AnyHashable: Any])

// Get the country data
let urlPath = NSBundle.mainBundle().pathForResource("countries_2015", ofType: "xml")
let urlPath = Bundle.main.path(forResource: "countries_2015", ofType: "xml")
var contents: NSString?
do {
contents = try NSString(contentsOfFile: urlPath!, encoding: NSUTF8StringEncoding)
contents = try NSString(contentsOfFile: urlPath!, encoding: String.Encoding.utf8.rawValue)
} catch _ {
contents = nil
}
Expand All @@ -55,7 +55,7 @@ class ConventionsTableViewController: UITableViewController {
ilo138Label.textColor = UIColor(red: 0.0, green: 0.75, blue: 0.0, alpha: 1.0)
} else if minimumAge.text! == "No" {
ilo138Label.text = "No"
ilo138Label.textColor = UIColor.redColor()
ilo138Label.textColor = UIColor.red
} else if minimumAge.text! == "N/A" {
ilo138Label.text = "N/A"
}
Expand All @@ -70,7 +70,7 @@ class ConventionsTableViewController: UITableViewController {
ilo182Label.textColor = UIColor(red: 0.0, green: 0.75, blue: 0.0, alpha: 1.0)
} else if worstForms.text! == "No" {
ilo182Label.text = "No"
ilo182Label.textColor = UIColor.redColor()
ilo182Label.textColor = UIColor.red
} else if worstForms.text! == "N/A" {
ilo182Label.text = "N/A"
}
Expand All @@ -85,7 +85,7 @@ class ConventionsTableViewController: UITableViewController {
unCRCLabel.textColor = UIColor(red: 0.0, green: 0.75, blue: 0.0, alpha: 1.0)
} else if unCRC.text! == "No" {
unCRCLabel.text = "No"
unCRCLabel.textColor = UIColor.redColor()
unCRCLabel.textColor = UIColor.red
} else if unCRC.text! == "N/A" {
unCRCLabel.text = "N/A"
}
Expand All @@ -100,7 +100,7 @@ class ConventionsTableViewController: UITableViewController {
unCRCArmedLabel.textColor = UIColor(red: 0.0, green: 0.75, blue: 0.0, alpha: 1.0)
} else if armedConflict.text! == "No" {
unCRCArmedLabel.text = "No"
unCRCArmedLabel.textColor = UIColor.redColor()
unCRCArmedLabel.textColor = UIColor.red
} else if armedConflict.text! == "N/A" {
unCRCArmedLabel.text = "N/A"
}
Expand All @@ -115,7 +115,7 @@ class ConventionsTableViewController: UITableViewController {
unCRCSaleLabel.textColor = UIColor(red: 0.0, green: 0.75, blue: 0.0, alpha: 1.0)
} else if sexualExploitation.text! == "No" {
unCRCSaleLabel.text = "No"
unCRCSaleLabel.textColor = UIColor.redColor()
unCRCSaleLabel.textColor = UIColor.red
} else if sexualExploitation.text! == "N/A" {
unCRCSaleLabel.text = "N/A"
}
Expand All @@ -130,7 +130,7 @@ class ConventionsTableViewController: UITableViewController {
unCRCTraffickingLabel.textColor = UIColor(red: 0.0, green: 0.75, blue: 0.0, alpha: 1.0)
} else if trafficking.text! == "No" {
unCRCTraffickingLabel.text = "No"
unCRCTraffickingLabel.textColor = UIColor.redColor()
unCRCTraffickingLabel.textColor = UIColor.red
} else if trafficking.text! == "N/A" {
unCRCTraffickingLabel.text = "N/A"
}
Expand All @@ -149,16 +149,16 @@ class ConventionsTableViewController: UITableViewController {

// MARK: - Table view data source

override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
override func numberOfSections(in tableView: UITableView) -> Int {
// #warning Incomplete implementation, return the number of sections
return 1
}

override func tableView(tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
return "Ratifications"
}

override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// #warning Incomplete implementation, return the number of rows
return 6
}
Expand Down
20 changes: 10 additions & 10 deletions Child Labor/CoordTableViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ class CoordTableViewController: UITableViewController {

// Record GA view
let tracker = GAI.sharedInstance().defaultTracker
tracker.set(kGAIScreenName, value: "Coordination Screen")
tracker.send(GAIDictionaryBuilder.createAppView().build() as [NSObject : AnyObject])
tracker?.set(kGAIScreenName, value: "Coordination Screen")
tracker?.send(GAIDictionaryBuilder.createAppView().build() as NSDictionary? as? [AnyHashable: Any])

self.tableView.estimatedRowHeight = 80.0
self.tableView.rowHeight = UITableViewAutomaticDimension
Expand All @@ -38,10 +38,10 @@ class CoordTableViewController: UITableViewController {


// Get the country data
let urlPath = NSBundle.mainBundle().pathForResource("countries_2015", ofType: "xml")
let urlPath = Bundle.main.path(forResource: "countries_2015", ofType: "xml")
var contents: NSString?
do {
contents = try NSString(contentsOfFile: urlPath!, encoding: NSUTF8StringEncoding)
contents = try NSString(contentsOfFile: urlPath!, encoding: String.Encoding.utf8.rawValue)
} catch _ {
contents = nil
}
Expand All @@ -56,14 +56,14 @@ class CoordTableViewController: UITableViewController {
}
}

func setMechanism(label: UILabel, text: String?) {
func setMechanism(_ label: UILabel, text: String?) {
if (text != nil) {
label.text = text
if (text!.hasPrefix("Yes") == true) {
label.textColor = UIColor(red: 0.0, green: 0.75, blue: 0.0, alpha: 1.0)
}
else if (text!.hasPrefix("No") == true) {
label.textColor = UIColor.redColor()
label.textColor = UIColor.red
}
}
}
Expand All @@ -75,12 +75,12 @@ class CoordTableViewController: UITableViewController {

// MARK: - Table view data source

override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
override func numberOfSections(in tableView: UITableView) -> Int {
// #warning Incomplete implementation, return the number of sections
return 3
}

override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// #warning Incomplete implementation, return the number of rows
if state == section {
return 1
Expand All @@ -89,12 +89,12 @@ class CoordTableViewController: UITableViewController {
return 1
}

@IBAction func changeSection(sender: AnyObject) {
@IBAction func changeSection(_ sender: AnyObject) {
state = sender.selectedSegmentIndex
self.tableView.reloadData()
}

override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return UITableViewAutomaticDimension
}

Expand Down
Loading