ios - LocationServicesEnabled: APIs deprecated -



ios - LocationServicesEnabled: APIs deprecated -

i utilize code here:

import uikit import corelocation @uiapplicationmain class appdelegate: uiresponder, uiapplicationdelegate, cllocationmanagerdelegate { var window: uiwindow? var locationmanager: cllocationmanager! var seenerror : bool = false var locationfixachieved : bool = false var locationstatus : nsstring = "not started" func application(application: uiapplication, didfinishlaunchingwithoptions launchoptions: nsdictionary?) -> bool { initlocationmanager(); homecoming true } // location manager helper stuff func initlocationmanager() { seenerror = false locationfixachieved = false locationmanager = cllocationmanager() locationmanager.delegate = self locationmanager.locationservicesenabled locationmanager.desiredaccuracy = kcllocationaccuracybest locationmanager.requestalwaysauthorization() } // location manager delegate stuff func locationmanager(manager: cllocationmanager!, didfailwitherror error: nserror!) { locationmanager.stopupdatinglocation() if (error) { if (seenerror == false) { seenerror = true print(error) } } } func locationmanager(manager: cllocationmanager!, didupdatelocations locations: anyobject[]!) { if (locationfixachieved == false) { locationfixachieved = true var locationarray = locations nsarray var locationobj = locationarray.lastobject cllocation var coord = locationobj.coordinate println(coord.latitude) println(coord.longitude) } } func locationmanager(manager: cllocationmanager!, didchangeauthorizationstatus status: clauthorizationstatus) { var shouldiallow = false switch status { case clauthorizationstatus.restricted: locationstatus = "restricted access location" case clauthorizationstatus.denied: locationstatus = "user denied access location" case clauthorizationstatus.notdetermined: locationstatus = "status not determined" default: locationstatus = "allowed location access" shouldiallow = true } nsnotificationcenter.defaultcenter().postnotificationname("labelhasbeenupdated", object: nil) if (shouldiallow == true) { nslog("location allowed") // start location services locationmanager.startupdatinglocation() } else { nslog("denied access: \(locationstatus)") } } }

but have error: 'locationservicesenabled' unavailable: apis deprecated of ios 7 , before unavailable in swift.

anyone know, how prepare that?

thanks!

the locationservicesenabled property on instance of cllocationmanager is deprecated of ios 4.0, class method not.

so instead of:

locationmanager.locationservicesenabled

you should utilize next instead:

cllocationmanager.locationservicesenabled()

ios swift

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -