Created
August 15, 2014 02:38
-
-
Save regnerjr/9794adb6c87ed1ceeeb7 to your computer and use it in GitHub Desktop.
Chapter 4 - BNR iOS Programming - Swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// ViewController.swift | |
// WhereAmI | |
// | |
// Created by John Regner on 8/13/14. | |
// Copyright (c) 2014 In Your Dreams Software. All rights reserved. | |
// | |
import UIKit | |
import CoreLocation | |
class ViewController: UIViewController, CLLocationManagerDelegate { | |
let locationManager = CLLocationManager() | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
//Configure Location Manager | |
locationManager.requestWhenInUseAuthorization() | |
locationManager.desiredAccuracy = kCLLocationAccuracyBest | |
locationManager.startUpdatingLocation() | |
locationManager.delegate = self | |
} | |
override func didReceiveMemoryWarning() { | |
super.didReceiveMemoryWarning() | |
// Dispose of any resources that can be recreated. | |
} | |
///MARK: CLLocationManager Delegate Methods | |
func locationManager(manager: CLLocationManager!, didUpdateLocations locations: [AnyObject]!) { | |
println("location changed") | |
println("number of locations \(locations.count)") | |
for index in 0..<locations.count { | |
println("\(locations[index] as CLLocation)") | |
} | |
} | |
func locationManager(manager: CLLocationManager!, didFailWithError error: NSError!) { | |
println("Could not find location: \(error)") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment