Revert "Swift 2.2"

This reverts commit 3f231652fd.

Conflicts:
	ios/SAPTracker/src/xcode/SAPTracker/HomeViewController.swift

Change-Id: I18f298df14821cc448521c5fda96773fb6765b44
This commit is contained in:
Axel Uhl committed 2016-03-31 17:46:51 +02:00
1 parent c2f75f1dd4
commit a5795fe70c
13 files changed
+38 -36

No files matched your search

@@ -63,7 +63,7 @@ public class APIManager: NSObject {
// set up reachability
let operationQueue = manager!.operationQueue
manager!.reachabilityManager.setReachabilityStatusChangeBlock({(status) -> Void in
manager!.reachabilityManager.setReachabilityStatusChangeBlock({(AFNetworkReachabilityStatus status) -> Void in
switch (status) {
case AFNetworkReachabilityStatus.ReachableViaWWAN, AFNetworkReachabilityStatus.ReachableViaWiFi:
operationQueue?.suspended = false
@@ -106,7 +106,7 @@ public class APIManager: NSObject {
}
public func teamImage(competitorId: String!, result: (imageUrl: String?) -> Void) {
getTeam(competitorId, success: { (operation, teamResponseObject) -> Void in
getTeam(competitorId, success: { (AFHTTPRequestOperation operation, AnyObject teamResponseObject) -> Void in
if let team = teamResponseObject as? [String: AnyObject],
let imageUrl = team["imageUri"] as? String {
@@ -115,7 +115,7 @@ public class APIManager: NSObject {
result(imageUrl: nil)
}
}, failure: { (operation, error) -> Void in
}, failure: { (AFHTTPRequestOperation operation, NSError error) -> Void in
// No image & that's ok
result(imageUrl: nil)
})
@@ -14,7 +14,7 @@ class CourseViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
NSNotificationCenter.defaultCenter().addObserver(self, selector:#selector(CourseViewController.newLocation(_:)), name:LocationManager.NotificationType.newLocation, object: nil)
NSNotificationCenter.defaultCenter().addObserver(self, selector:"newLocation:", name:LocationManager.NotificationType.newLocation, object: nil)
}
deinit {
@@ -26,10 +26,10 @@ public class DataManager: NSObject {
print(managedObjectContext!)
// store new locations to database
NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(DataManager.newLocation(_:)), name: LocationManager.NotificationType.newLocation, object: nil)
NSNotificationCenter.defaultCenter().addObserver(self, selector: "newLocation:", name: LocationManager.NotificationType.newLocation, object: nil)
// save context when done tracking
NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(DataManager.trackingStopped(_:)), name: LocationManager.NotificationType.trackingStopped, object: nil)
NSNotificationCenter.defaultCenter().addObserver(self, selector: "trackingStopped:", name: LocationManager.NotificationType.trackingStopped, object: nil)
}
deinit {
@@ -33,8 +33,8 @@ class GPSAccuracyView : UIView {
barView.frame = bounds
// add listeners
NSNotificationCenter.defaultCenter().addObserver(self, selector:#selector(GPSAccuracyView.newLocation(_:)), name:LocationManager.NotificationType.newLocation, object: nil)
NSNotificationCenter.defaultCenter().addObserver(self, selector:#selector(GPSAccuracyView.locationManagerFailed(_:)), name:LocationManager.NotificationType.locationManagerFailed, object: nil)
NSNotificationCenter.defaultCenter().addObserver(self, selector:"newLocation:", name:LocationManager.NotificationType.newLocation, object: nil)
NSNotificationCenter.defaultCenter().addObserver(self, selector:"locationManagerFailed:", name:LocationManager.NotificationType.locationManagerFailed, object: nil)
}
+4 -2
View File
@@ -45,9 +45,9 @@ class HomeViewController: UIViewController, UITableViewDataSource, UITableViewDe
}
// register for open custom URL events
NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(HomeViewController.openUrl(_:)), name: AppDelegate.NotificationType.openUrl, object: nil)
NSNotificationCenter.defaultCenter().addObserver(self, selector: "openUrl:", name: AppDelegate.NotificationType.openUrl, object: nil)
NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(HomeViewController.checkEULA(_:)), name: UIApplicationWillEnterForegroundNotification, object: nil)
NSNotificationCenter.defaultCenter().addObserver(self, selector: "checkEULA:", name: UIApplicationWillEnterForegroundNotification, object: nil)
checkEULA(NSNotification.init(name: "", object: nil))
@@ -193,6 +193,8 @@ class HomeViewController: UIViewController, UITableViewDataSource, UITableViewDe
tableView.insertRowsAtIndexPaths([newIndexPath!], withRowAnimation: .Automatic)
case .Delete:
tableView.deleteRowsAtIndexPaths([indexPath!], withRowAnimation: UITableViewRowAnimation.Automatic)
default:
return
}
}
@@ -16,7 +16,7 @@ class LeaderBoardViewController: UIViewController, UIWebViewDelegate, UIAlertVie
override func viewDidLoad() {
super.viewDidLoad()
let serverUrl = DataManager.sharedManager.selectedCheckIn!.serverUrl
// let eventId = DataManager.sharedManager.selectedCheckIn!.eventId
let eventId = DataManager.sharedManager.selectedCheckIn!.eventId
let leaderBoardName = DataManager.sharedManager.selectedCheckIn!.leaderBoardName.stringByAddingPercentEscapesUsingEncoding(NSUTF8StringEncoding)!
let url = "\(serverUrl)/gwt/Leaderboard.html?name=\(leaderBoardName)&showRaceDetails=false&embedded=true&hideToolbar=true"
webView!.loadRequest(NSURLRequest(URL: NSURL(string: url)!))
@@ -42,7 +42,7 @@ class LocationManager: NSObject, CLLocationManagerDelegate {
if (CLLocationManager.authorizationStatus() == CLAuthorizationStatus.Denied) {
return NSLocalizedString("Please enable location services for this app.", comment: "")
}
if (coreLocationManager.respondsToSelector(#selector(CLLocationManager.requestAlwaysAuthorization))) {
if (coreLocationManager.respondsToSelector("requestAlwaysAuthorization")) {
coreLocationManager.requestAlwaysAuthorization()
}
coreLocationManager.startUpdatingLocation()
@@ -62,13 +62,13 @@ class LocationManager: NSObject, CLLocationManagerDelegate {
NSNotificationQueue.defaultQueue().enqueueNotification(notification, postingStyle: NSPostingStyle.PostASAP)
}
func locationManager(manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
func locationManager(manager: CLLocationManager!, didUpdateLocations locations: [CLLocation]!) {
let location = locations.last
let notification = NSNotification(name: NotificationType.newLocation, object: self, userInfo:LocationManager.dictionaryForLocation(location!))
NSNotificationQueue.defaultQueue().enqueueNotification(notification, postingStyle: NSPostingStyle.PostASAP)
}
func locationManager(manager: CLLocationManager, didFailWithError error: NSError) {
func locationManager(manager: CLLocationManager!, didFailWithError error: NSError!) {
let notification = NSNotification(name: NotificationType.locationManagerFailed, object: self, userInfo: ["error": error])
NSNotificationQueue.defaultQueue().enqueueNotification(notification, postingStyle: NSPostingStyle.PostASAP)
}
@@ -11,7 +11,7 @@ import UIKit
import AVFoundation
@objc protocol QRCodeManagerDelegate {
optional var activityIndicatorView: UIActivityIndicatorView! { get }
optional var activityIndicatorView: UIActivityIndicatorView { get }
optional func qrCodeOK()
optional func qrCodeCancel()
}
@@ -96,17 +96,17 @@ class QRCodeManager : NSObject, UIAlertViewDelegate {
// get event
APIManager.sharedManager.getEvent(qrcodeData!.eventId,
success: { (operation, eventResponseObject) -> Void in
success: { (AFHTTPRequestOperation operation, AnyObject eventResponseObject) -> Void in
self.eventDictionary = eventResponseObject as? [String: AnyObject]
APIManager.sharedManager.getLeaderBoard(self.qrcodeData!.leaderBoardName,
// get leader board
success: { (operation, leaderBoardResponseObject) -> Void in
success: { (AFHTTPRequestOperation operation, AnyObject leaderBoardResponseObject) -> Void in
self.leaderBoardDictionary = leaderBoardResponseObject as? [String: AnyObject]
APIManager.sharedManager.getCompetitor(self.qrcodeData!.competitorId,
// get competitor
success: { (operation, competitorResponseObject) -> Void in
success: { (AFHTTPRequestOperation operation, AnyObject competitorResponseObject) -> Void in
APIManager.sharedManager.teamImage(self.qrcodeData!.competitorId, result: { (imageUrl) -> Void in
@@ -125,14 +125,14 @@ class QRCodeManager : NSObject, UIAlertViewDelegate {
alertView.show()
})
}, failure: { (operation, error) -> Void in
}, failure: { (AFHTTPRequestOperation operation, NSError error) -> Void in
self.delegate.activityIndicatorView?.stopAnimating()
let title = String(format: NSLocalizedString("Couldn't get competitor %@", comment: ""), self.qrcodeData!.competitorId!)
let alertView = UIAlertView(title: title, message: error.localizedDescription, delegate: self, cancelButtonTitle: NSLocalizedString("Cancel", comment: ""))
alertView.tag = AlertView.ServerError.rawValue;
alertView.show()
}) }, failure: { (operation, error) -> Void in
}) }, failure: { (AFHTTPRequestOperation operation, NSError error) -> Void in
self.delegate.activityIndicatorView?.stopAnimating()
let title = String(format: NSLocalizedString("Couldn't get leader board %@", comment: ""), self.qrcodeData!.leaderBoardName!)
let alertView = UIAlertView(title: title, message: error.localizedDescription, delegate: self, cancelButtonTitle: NSLocalizedString("Cancel", comment: ""))
@@ -140,7 +140,7 @@ class QRCodeManager : NSObject, UIAlertViewDelegate {
alertView.show()
})
}, failure: { (operation, error) -> Void in
}, failure: { (AFHTTPRequestOperation operation, NSError error) -> Void in
self.delegate.activityIndicatorView?.stopAnimating()
let title = String(format: NSLocalizedString("Couldn't get event %@", comment: ""), self.qrcodeData!.eventId!)
let alertView = UIAlertView(title: title, message: error.localizedDescription, delegate: self, cancelButtonTitle: NSLocalizedString("Cancel", comment: ""))
@@ -185,7 +185,7 @@ class QRCodeManager : NSObject, UIAlertViewDelegate {
checkIn.imageUrl = teamImageURL
APIManager.sharedManager.checkIn(leaderBoardName, competitorId: competitorId, deviceUuid: DeviceUDIDManager.UDID, pushDeviceId: "", fromMillis: fromMillis,
success: { (operation, eventResponseObject) -> Void in
success: { (AFHTTPRequestOperation operation, AnyObject eventResponseObject) -> Void in
// create core data objects
let event = DataManager.sharedManager.newEvent(checkIn)
@@ -197,7 +197,7 @@ class QRCodeManager : NSObject, UIAlertViewDelegate {
DataManager.sharedManager.saveContext()
self.delegate.qrCodeOK?()
}, failure: { (operation, error) -> Void in
}, failure: { (AFHTTPRequestOperation operation, NSError error) -> Void in
self.delegate.activityIndicatorView?.stopAnimating()
let title = String(format:NSLocalizedString("Couldn't check-in to %@", comment: ""), leaderBoardName);
let alertView = UIAlertView(title: title, message: error.localizedDescription, delegate: self, cancelButtonTitle: NSLocalizedString("Cancel", comment: ""))
@@ -183,7 +183,7 @@ class RegattaViewController : UIViewController, UIActionSheetDelegate, UINavigat
hoursLabel.text = String(format: "%.0f", arguments: [hours])
minutesLabel.text = String(format: "%.0f", arguments: [minutes])
loop?.invalidate()
loop = NSTimer(timeInterval: 60, target: self, selector: #selector(RegattaViewController.checkRegattaStatus), userInfo: nil, repeats: false)
loop = NSTimer(timeInterval: 60, target: self, selector: "checkRegattaStatus", userInfo: nil, repeats: false)
NSRunLoop.currentRunLoop().addTimer(loop!, forMode:NSRunLoopCommonModes)
}
// during race
@@ -279,7 +279,7 @@ class RegattaViewController : UIViewController, UIActionSheetDelegate, UINavigat
DataManager.sharedManager.selectedCheckIn!.userImage = jpegData
APIManager.sharedManager.postTeamImage(DataManager.sharedManager.selectedCheckIn!.competitorId,
imageData: jpegData,
success: { (responseObject) -> Void in
success: { (AnyObject responseObject) -> Void in
// http://wiki.sapsailing.com/wiki/tracking-app/api-v1#Competitor-Information-%28in-general%29
// "Additional Notes: Competitor profile image left out for now."
let responseDictionary = responseObject as![String: AnyObject]
@@ -289,7 +289,7 @@ class RegattaViewController : UIViewController, UIActionSheetDelegate, UINavigat
NSUserDefaults.standardUserDefaults().setBool(false, forKey: self.uploadKey)
NSUserDefaults.standardUserDefaults().synchronize()
},
failure: { (error) -> Void in
failure: { (NSError error) -> Void in
let alertView = UIAlertView(title: NSLocalizedString("Failed to upload image", comment: ""), message: error.localizedDescription, delegate: self, cancelButtonTitle: NSLocalizedString("Cancel", comment: ""))
alertView.tag = AlertView.UploadFailed.rawValue;
alertView.show()
@@ -323,9 +323,9 @@ class RegattaViewController : UIViewController, UIActionSheetDelegate, UINavigat
competitorId: DataManager.sharedManager.selectedCheckIn!.competitorId,
deviceUuid: DeviceUDIDManager.UDID,
toMillis: toMillis,
success: { (operation, competitorResponseObject) -> Void in
success: { (AFHTTPRequestOperation operation, AnyObject competitorResponseObject) -> Void in
},
failure: { (operation, error) -> Void in
failure: { (AFHTTPRequestOperation operation, NSError error) -> Void in
}
)
DataManager.sharedManager.deleteCheckIn(DataManager.sharedManager.selectedCheckIn!)
@@ -43,7 +43,7 @@ class SendGPSFixController: NSObject {
/* See if any rows need to be uploaded. Schedule timer again. */
func timer() {
let loop = NSTimer.scheduledTimerWithTimeInterval(syncPeriod, target:self, selector:#selector(SendGPSFixController.timer), userInfo:nil, repeats:false)
let loop = NSTimer.scheduledTimerWithTimeInterval(syncPeriod, target:self, selector:"timer", userInfo:nil, repeats:false)
NSRunLoop.currentRunLoop().addTimer(loop, forMode:NSRunLoopCommonModes)
// get last 100 locations
@@ -80,7 +80,7 @@ class SendGPSFixController: NSObject {
APIManager.sharedManager.initManager(serverUrl)
if APIManager.sharedManager.networkAvailable {
APIManager.sharedManager.postGPSFixes(DeviceUDIDManager.UDID, gpsFixes: gpsFixes,
success: { (operation, competitorResponseObject) -> Void in
success: { (AFHTTPRequestOperation operation, AnyObject competitorResponseObject) -> Void in
print("sent GPS fixes")
for gpsFix in gpsFixes {
DataManager.sharedManager.managedObjectContext!.deleteObject(gpsFix)
@@ -88,7 +88,7 @@ class SendGPSFixController: NSObject {
let notification = NSNotification(name: NotificationType.gpsFixesSynced, object: self)
NSNotificationQueue.defaultQueue().enqueueNotification(notification, postingStyle: NSPostingStyle.PostASAP)
},
failure: { (operation, error) -> Void in
failure: { (AFHTTPRequestOperation operation, NSError error) -> Void in
print("error sending GPS fixes")
})
}
@@ -16,7 +16,7 @@ class SpeedViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
NSNotificationCenter.defaultCenter().addObserver(self, selector:#selector(SpeedViewController.newLocation(_:)), name:LocationManager.NotificationType.newLocation, object: nil)
NSNotificationCenter.defaultCenter().addObserver(self, selector:"newLocation:", name:LocationManager.NotificationType.newLocation, object: nil)
}
deinit {
@@ -19,7 +19,7 @@ class TimerViewController: UIViewController {
super.viewDidLoad()
// start tracking timer
let timer = NSTimer(timeInterval: 0.1, target: self, selector: #selector(TimerViewController.timer(_:)), userInfo: nil, repeats: true)
let timer = NSTimer(timeInterval: 0.1, target: self, selector: "timer:", userInfo: nil, repeats: true)
NSRunLoop.currentRunLoop().addTimer(timer, forMode:NSRunLoopCommonModes)
dateFormatter.dateFormat = "HH:mm:ss"
dateFormatter.timeZone = NSTimeZone(forSecondsFromGMT: 0)
@@ -35,9 +35,9 @@ class TrackingViewController : UIViewController {
networkAvailabilityChanged()
// register for notifications
NSNotificationCenter.defaultCenter().addObserver(self, selector:#selector(TrackingViewController.networkAvailabilityChanged), name:APIManager.NotificationType.networkAvailabilityChanged, object: nil)
NSNotificationCenter.defaultCenter().addObserver(self, selector:#selector(TrackingViewController.newLocation(_:)), name:LocationManager.NotificationType.newLocation, object: nil)
NSNotificationCenter.defaultCenter().addObserver(self, selector:#selector(TrackingViewController.locationManagerFailed(_:)), name:LocationManager.NotificationType.locationManagerFailed, object: nil)
NSNotificationCenter.defaultCenter().addObserver(self, selector:"networkAvailabilityChanged", name:APIManager.NotificationType.networkAvailabilityChanged, object: nil)
NSNotificationCenter.defaultCenter().addObserver(self, selector:"newLocation:", name:LocationManager.NotificationType.newLocation, object: nil)
NSNotificationCenter.defaultCenter().addObserver(self, selector:"locationManagerFailed:", name:LocationManager.NotificationType.locationManagerFailed, object: nil)
}
// MARK:- Buttons