I am fairly new to programming for iOS and am teaching myself how to use Swift. I need to set up geofencing for an app I am making for a class. My problem is when initializing CLCircularRegion I get an error that says "Use of undeclared type 'center'". I followed the documents from Apple's developer site and have no clue what I am doing wrong. Any help would be greatly appreciated. Thank you.
import UIKit
import MapKit
import CoreLocation
class ViewController: UIViewController, MKMapViewDelegate, CLLocationManagerDelegate {
@IBOutlet var mapView: MKMapView!
var manager = CLLocationManager()
@IBAction func startMonitoring(sender: AnyObject) {
// 43.039278, -87.932479 mccormick hall location
var latitude:CLLocationDegrees = 43.039278
var longitude:CLLocationDegrees = -87.932479
var center:CLLocationCoordinate2D = CLLocationCoordinate2DMake(latitude, longitude)
var radius:CLLocationDistance = CLLocationDistance(10.0)
var identifier:String = "vicmic"
var geoRegion:CLCircularRegion = CLCircularRegion(center: center, radius: radius, identifier: identifier)
}
override func viewDidLoad() {
super.viewDidLoad()
// Core Location
manager.delegate = self
manager.desiredAccuracy = kCLLocationAccuracyBest
manager.requestWhenInUseAuthorization()
manager.startUpdatingLocation()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
Broadly .... the code seems ok
1) try to leave spaces before type annotation, example from var center:CLLocationCoordinate2D
to this var center: CLLocationCoordinate2D
and
2) try to clean your DerivedData, restart Xcode..