ios - Swift 2 Core Location not working -


i trying set corelocation using swift 2 (xcode 7 beta, ios 9), "didupdatelocations" function never being called. appreciate get. here code:

// //  zmanimcontroller.swift //  yidkit // //  created dani smith on 7/12/15. //  copyright © 2015 daniel smith. rights reserved. //  import foundation import corelocation  class zmanimcontroller: nsobject, cllocationmanagerdelegate { //variables***************************************** let locationmanager = cllocationmanager() var lat = 0.0 var long = 0.0 var alt = 0.0 var koshercocoalocation: kcgeolocation = kcgeolocation() let dateformatter = nsdateformatter()  //the zmanim calendar   override init() {     super.init()     self.locationmanager.requestwheninuseauthorization()      locationmanager.desiredaccuracy = kcllocationaccuracybest     locationmanager.delegate = self     locationmanager.requestwheninuseauthorization()     locationmanager.startupdatinglocation()      //calendars     let zmanimcalendar: kccomplexzmanimcalendar = kccomplexzmanimcalendar(location: koshercocoalocation)     let astronomicalcalendar: kcastronomicalcalendar = kcastronomicalcalendar(location: koshercocoalocation)     astronomicalcalendar.workingdate = nsdate()      //date formatter stuff     dateformatter.timestyle = .mediumstyle     dateformatter.timezone = nstimezone.localtimezone()      print(dateformatter.stringfromdate(zmanimcalendar.alos72()))  }   //loacation stuff************************** func locationmanager(manager: cllocationmanager, didupdatelocations locations: [cllocation]) {     var latestlocation: anyobject = locations[locations.count - 1]     let locationarray = locations nsarray     let locationobj = locationarray.lastobject as! cllocation     let coord = locationobj.coordinate      var latitude = string(format: "%.4f",         coord.latitude)     var longitude = string(format: "%.4f",         coord.longitude)     var horizontalaccuracy = string(format: "%.4f",         latestlocation.horizontalaccuracy)     var altitude = string(format: "%.4f",         latestlocation.altitude)     var verticalaccuracy = string(format: "%.4f",         latestlocation.verticalaccuracy)     print(latitude)     print("wooe3reds") }  func locationmanager(manager: cllocationmanager, didfailwitherror error: nserror) {     print("error") }  } 

thanks!

update: here how initialize it:

import foundation import uikit  class zmanimviewcontroller: yidcontroller { override func viewdidload() {     let controller = zmanimcontroller()  } } 

as allocating zmanimcontroller instance local variable inside viewdidload released function returns.

you should allocate object instance object property of yidcontroller, way have same lifetime object instance.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -