Initialize CLCircularRegion in Swift

I am new to iOS programming and I am teaching how to use Swift. I need to configure geofencing for an application I am making for a class. My problem is when I initialize CLCircularRegion I get the error " Using an undeclared type center. " I followed the docs from the Apple developer site and have no idea what I am doing wrong. Any help would be greatly appreciated. Thanks.

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.
}


}

      

+3


source to share


1 answer


All in all .... the code looks ok

1) try leaving spaces before the type annotation, example from var center:CLLocationCoordinate2D

before var center: CLLocationCoordinate2D

and



2) try to clear DerivedData, restart Xcode ..

+1


source







All Articles