Caleb Caleb - 1 year ago 115
iOS Question

Getting initializer error on VewController

I get the error: "Class 'ViewController' has no initializer". I have narrowed down the problem to this function that is being called. Does anyone see the problem?

let locationManager1: CLLocationManager // your location manager
func addBoundry(loc: CLLocation)
if let loc: CLLocation! = locationManager1.location {
let center: CLLocationCoordinate2D = loc!.coordinate
let lat: CLLocationDegrees = center.latitude
let long: CLLocationDegrees = center.longitude
var points = [CLLocationCoordinate2DMake(lat,long),CLLocationCoordinate2DMake(lat,long),CLLocationCoordinate2DMake(lat,long),CLLocationCoordinate2DMake(lat,long)]
let polygon = MKPolygon(coordinates: &points, count: points.count)


} else {
print("no location...")

Answer Source

when assign property use optional.

 let locationManager1: CLLocationManager?
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download