From f8173e16d731bdb882c5e9e8fe2a0d9d3d6b89f4 Mon Sep 17 00:00:00 2001 From: Divesh Goyal Date: Tue, 9 Jun 2015 11:39:42 -0700 Subject: [PATCH 1/2] changes for swift 1.2 --- .../swift/MyFirstMapApp/AppDelegate.swift | 15 +++++++-------- .../swift/MyFirstMapApp/AppDelegate.swift | 13 ++++++------- .../swift/MyFirstMapApp/AppDelegate.swift | 13 ++++++------- .../swift/MyFirstMapApp/ViewController.swift | 6 +++--- .../swift/MyFirstMapApp/AppDelegate.swift | 13 ++++++------- .../swift/MyFirstMapApp/ViewController.swift | 4 ++-- .../swift/MyFirstMapApp/AppDelegate.swift | 13 ++++++------- .../MyFirstMapApp/Base.lproj/Main.storyboard | 9 +++++---- .../swift/MyFirstMapApp/ViewController.swift | 18 +++++++++--------- 9 files changed, 50 insertions(+), 54 deletions(-) diff --git a/Add Map Tutorial/swift/MyFirstMapApp/AppDelegate.swift b/Add Map Tutorial/swift/MyFirstMapApp/AppDelegate.swift index 8c626c6..b4584f0 100644 --- a/Add Map Tutorial/swift/MyFirstMapApp/AppDelegate.swift +++ b/Add Map Tutorial/swift/MyFirstMapApp/AppDelegate.swift @@ -22,30 +22,29 @@ class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? - func application(application: UIApplication!, didFinishLaunchingWithOptions launchOptions: NSDictionary!) -> Bool { - // Override point for customization after application launch. + func application(application: UIApplication, willFinishLaunchingWithOptions launchOptions: [NSObject : AnyObject]?) -> Bool { 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:. } diff --git a/Basemap Tutorial/swift/MyFirstMapApp/AppDelegate.swift b/Basemap Tutorial/swift/MyFirstMapApp/AppDelegate.swift index 8c626c6..e563259 100644 --- a/Basemap Tutorial/swift/MyFirstMapApp/AppDelegate.swift +++ b/Basemap Tutorial/swift/MyFirstMapApp/AppDelegate.swift @@ -22,30 +22,29 @@ class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? - func application(application: UIApplication!, didFinishLaunchingWithOptions launchOptions: NSDictionary!) -> Bool { - // Override point for customization after application launch. + func application(application: UIApplication, willFinishLaunchingWithOptions launchOptions: [NSObject : AnyObject]?) -> Bool { 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:. } diff --git a/Cloud Data Tutorial/swift/MyFirstMapApp/AppDelegate.swift b/Cloud Data Tutorial/swift/MyFirstMapApp/AppDelegate.swift index 8c626c6..e563259 100644 --- a/Cloud Data Tutorial/swift/MyFirstMapApp/AppDelegate.swift +++ b/Cloud Data Tutorial/swift/MyFirstMapApp/AppDelegate.swift @@ -22,30 +22,29 @@ class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? - func application(application: UIApplication!, didFinishLaunchingWithOptions launchOptions: NSDictionary!) -> Bool { - // Override point for customization after application launch. + func application(application: UIApplication, willFinishLaunchingWithOptions launchOptions: [NSObject : AnyObject]?) -> Bool { 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:. } diff --git a/Cloud Data Tutorial/swift/MyFirstMapApp/ViewController.swift b/Cloud Data Tutorial/swift/MyFirstMapApp/ViewController.swift index 91a2f65..6698be5 100644 --- a/Cloud Data Tutorial/swift/MyFirstMapApp/ViewController.swift +++ b/Cloud Data Tutorial/swift/MyFirstMapApp/ViewController.swift @@ -106,7 +106,7 @@ class ViewController: UIViewController, AGSMapViewLayerDelegate, UIPickerViewDel func pickerView(pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) { let countryName = self.countries[row] - let featureLayer = self.mapView.mapLayerForName("CloudData") as AGSFeatureLayer + let featureLayer = self.mapView.mapLayerForName("CloudData") as! AGSFeatureLayer if featureLayer.selectionSymbol == nil { //SYMBOLOGY FOR WHERE CLAUSE SELECTION @@ -143,12 +143,12 @@ class ViewController: UIViewController, AGSMapViewLayerDelegate, UIPickerViewDel func featureLayer(featureLayer: AGSFeatureLayer!, operation op: NSOperation!, didSelectFeaturesWithFeatureSet featureSet: AGSFeatureSet!) { //ZOOM TO SELECTED DATA var env:AGSMutableEnvelope! - for selectedFeature in featureSet.features as [AGSGraphic]{ + for selectedFeature in featureSet.features as! [AGSGraphic]{ if env != nil { env.unionWithEnvelope(selectedFeature.geometry.envelope) } else { - env = selectedFeature.geometry.envelope.mutableCopy() as AGSMutableEnvelope + env = selectedFeature.geometry.envelope.mutableCopy() as! AGSMutableEnvelope } } self.mapView.zoomToGeometry(env, withPadding: 20, animated: true) diff --git a/Geocoding Tutorial/swift/MyFirstMapApp/AppDelegate.swift b/Geocoding Tutorial/swift/MyFirstMapApp/AppDelegate.swift index 8c626c6..e563259 100644 --- a/Geocoding Tutorial/swift/MyFirstMapApp/AppDelegate.swift +++ b/Geocoding Tutorial/swift/MyFirstMapApp/AppDelegate.swift @@ -22,30 +22,29 @@ class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? - func application(application: UIApplication!, didFinishLaunchingWithOptions launchOptions: NSDictionary!) -> Bool { - // Override point for customization after application launch. + func application(application: UIApplication, willFinishLaunchingWithOptions launchOptions: [NSObject : AnyObject]?) -> Bool { 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:. } diff --git a/Geocoding Tutorial/swift/MyFirstMapApp/ViewController.swift b/Geocoding Tutorial/swift/MyFirstMapApp/ViewController.swift index 484efa2..7613ad3 100644 --- a/Geocoding Tutorial/swift/MyFirstMapApp/ViewController.swift +++ b/Geocoding Tutorial/swift/MyFirstMapApp/ViewController.swift @@ -119,12 +119,12 @@ class ViewController: UIViewController, AGSMapViewLayerDelegate, UISearchBarDele } //Add a graphic for each result - for result in results as [AGSLocatorFindResult] { + for result in results as! [AGSLocatorFindResult] { self.graphicLayer.addGraphic(result.graphic) } //Zoom in to the results - let extent = self.graphicLayer.fullEnvelope.mutableCopy() as AGSMutableEnvelope + let extent = self.graphicLayer.fullEnvelope.mutableCopy() as! AGSMutableEnvelope extent.expandByFactor(1.5) self.mapView.zoomToEnvelope(extent, animated: true) } diff --git a/Routing Tutorial/swift/MyFirstMapApp/AppDelegate.swift b/Routing Tutorial/swift/MyFirstMapApp/AppDelegate.swift index 8c626c6..e563259 100644 --- a/Routing Tutorial/swift/MyFirstMapApp/AppDelegate.swift +++ b/Routing Tutorial/swift/MyFirstMapApp/AppDelegate.swift @@ -22,30 +22,29 @@ class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? - func application(application: UIApplication!, didFinishLaunchingWithOptions launchOptions: NSDictionary!) -> Bool { - // Override point for customization after application launch. + func application(application: UIApplication, willFinishLaunchingWithOptions launchOptions: [NSObject : AnyObject]?) -> Bool { 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:. } diff --git a/Routing Tutorial/swift/MyFirstMapApp/Base.lproj/Main.storyboard b/Routing Tutorial/swift/MyFirstMapApp/Base.lproj/Main.storyboard index 0951119..621d93b 100644 --- a/Routing Tutorial/swift/MyFirstMapApp/Base.lproj/Main.storyboard +++ b/Routing Tutorial/swift/MyFirstMapApp/Base.lproj/Main.storyboard @@ -1,8 +1,8 @@ - + - - + + @@ -59,7 +59,7 @@ - + @@ -88,6 +88,7 @@ + diff --git a/Routing Tutorial/swift/MyFirstMapApp/ViewController.swift b/Routing Tutorial/swift/MyFirstMapApp/ViewController.swift index 2a9c4ba..3276bf9 100644 --- a/Routing Tutorial/swift/MyFirstMapApp/ViewController.swift +++ b/Routing Tutorial/swift/MyFirstMapApp/ViewController.swift @@ -68,7 +68,7 @@ class ViewController: UIViewController, AGSMapViewLayerDelegate, UISearchBarDele //MARK: search bar delegate methods - func searchBarSearchButtonClicked(searchBar: UISearchBar!) { + func searchBarSearchButtonClicked(searchBar: UISearchBar) { //Hide the keyboard searchBar.resignFirstResponder() @@ -130,13 +130,13 @@ class ViewController: UIViewController, AGSMapViewLayerDelegate, UISearchBarDele } //Add a graphic for each result - for result in results as [AGSLocatorFindResult] { + for result in results as! [AGSLocatorFindResult] { let graphic = result.graphic self.graphicLayer.addGraphic(graphic) } //Zoom in to the results - let extent = self.graphicLayer.fullEnvelope.mutableCopy() as AGSMutableEnvelope + let extent = self.graphicLayer.fullEnvelope.mutableCopy() as! AGSMutableEnvelope extent.expandByFactor(1.5) self.mapView.zoomToEnvelope(extent, animated: true) } @@ -149,7 +149,7 @@ class ViewController: UIViewController, AGSMapViewLayerDelegate, UISearchBarDele //MARK: AGSCalloutDelegate methods func didClickAccessoryButtonForCallout(callout: AGSCallout!) { - let graphic = callout.representedObject as AGSGraphic + let graphic = callout.representedObject as! AGSGraphic let destinationLocation = graphic.geometry self.routeTo(destinationLocation) @@ -157,7 +157,7 @@ class ViewController: UIViewController, AGSMapViewLayerDelegate, UISearchBarDele func routeTo(destination:AGSGeometry) { //update the banner - self.directionsLabel.text = "Routing" + self.directionsLabel.text = "Routing..." if self.routeTask == nil { self.routeTask = AGSRouteTask(URL: NSURL(string: "http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Network/USA/NAServer/Route")) @@ -237,7 +237,7 @@ class ViewController: UIViewController, AGSMapViewLayerDelegate, UISearchBarDele @IBAction func prevBtnClicked(sender: AnyObject) { var index = 0 if self.currentDirectionGraphic != nil { - if let currentIndex = find(self.routeResult.directions.graphics as [AGSDirectionGraphic], self.currentDirectionGraphic) { + if let currentIndex = find(self.routeResult.directions.graphics as! [AGSDirectionGraphic], self.currentDirectionGraphic) { index = currentIndex - 1 } } @@ -247,7 +247,7 @@ class ViewController: UIViewController, AGSMapViewLayerDelegate, UISearchBarDele @IBAction func nextBtnClicked(sender: AnyObject) { var index = 0 if self.currentDirectionGraphic != nil { - if let currentIndex = find(self.routeResult.directions.graphics as [AGSDirectionGraphic], self.currentDirectionGraphic) { + if let currentIndex = find(self.routeResult.directions.graphics as! [AGSDirectionGraphic], self.currentDirectionGraphic) { index = currentIndex + 1 } } @@ -260,7 +260,7 @@ class ViewController: UIViewController, AGSMapViewLayerDelegate, UISearchBarDele //get current direction and add it to the graphics layer let directions = self.routeResult.directions as AGSDirectionSet - self.currentDirectionGraphic = directions.graphics[index] as AGSDirectionGraphic + self.currentDirectionGraphic = directions.graphics[index] as! AGSDirectionGraphic //highlight current manoeuver with a different symbol let cs = AGSCompositeSymbol() @@ -283,7 +283,7 @@ class ViewController: UIViewController, AGSMapViewLayerDelegate, UISearchBarDele self.directionsLabel.text = self.currentDirectionGraphic.text //soom to envelope of the current direction (expanded by a factor of 1.3) - let env = self.currentDirectionGraphic.geometry.envelope.mutableCopy() as AGSMutableEnvelope + let env = self.currentDirectionGraphic.geometry.envelope.mutableCopy() as! AGSMutableEnvelope env.expandByFactor(1.3) self.mapView.zoomToEnvelope(env, animated: true) From 6d7ce6585c8d86ec418ffe339acbd5e91497d4a5 Mon Sep 17 00:00:00 2001 From: Divesh Goyal Date: Tue, 9 Jun 2015 11:50:11 -0700 Subject: [PATCH 2/2] updated read --- README.md | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 19f308d..dc2d60b 100644 --- a/README.md +++ b/README.md @@ -9,9 +9,17 @@ The ```master``` branch of this repository contains samples configured for the l [New to Github? Get started here.](http://htmlpreview.github.com/?https://github.com/Esri/esri.github.com/blob/master/help/esri-getting-to-know-github.html) ## Requirements -* XCode 5 (or higher) -* iOS 7 SDK (or higher) -* [ArcGIS Runtime SDK for iOS](https://developers.arcgis.com/en/ios/) (Requires ArcGIS for Developers account; free to sign up) + +[ArcGIS Runtime SDK for iOS](https://developers.arcgis.com/en/ios/) (Requires ArcGIS for Developers account; free to sign up) + +For Objective-C : + * XCode 5 (or higher) + * iOS 7 SDK (or higher) + +For Swift : + * XCode 6.3 (or higher) + * iOS 8 SDK (or higher) + ##Additional Resources