Created
May 26, 2015 21:07
-
-
Save gmertk/1252284c4a5ce10bbd58 to your computer and use it in GitHub Desktop.
When you monitor a region initialized with only UUID, didEnterRegion won't give you major and minor.
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
import UIKit | |
import CoreLocation | |
class ViewController: UIViewController, CLLocationManagerDelegate { | |
var manager = CLLocationManager() | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
manager.delegate = self | |
manager.requestAlwaysAuthorization() | |
if let uuid = NSUUID(UUIDString: "B9407F30-F5F8-466E-AFF9-25556B57FE6D") { | |
let region = CLBeaconRegion(proximityUUID: uuid, identifier: uuid.UUIDString) | |
manager.startMonitoringForRegion(region) | |
} | |
} | |
// MARK: CLLocationManagerDelegate | |
func locationManager(manager: CLLocationManager!, didEnterRegion region: CLRegion!) { | |
if let region = region as? CLBeaconRegion { | |
// region.major and region.minor will return nil | |
println("Entered in region with UUID: \(region.proximityUUID) Major: \(region.major) Minor: \(region.minor)") | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment