xcode - IOS 8 swift CoreLocation -
im learning xcode 6.3 , swift , following book apress beginning xcode swift, in chapter 4 when doing first tab location tracker shows nothing @ , i'm confused. code first tab this
import uikit import corelocation class trackviewcontroller: uiviewcontroller, cllocationmanagerdelegate { var locationmanager: cllocationmanager! @iboutlet weak var locationtext: uitextview! @iboutlet weak var toggleswitch: uiswitch! override func viewdidload() { super.viewdidload() // additional setup after loading view, typically nib. } override func didreceivememorywarning() { super.didreceivememorywarning() // dispose of resources can recreated. } @ibaction func changetoggle(sender: uiswitch) { if toggleswitch.on { self.locationtext.text = " " if (cllocationmanager.locationservicesenabled() == false) { self.toggleswitch.on = false } if locationmanager == nil { locationmanager = cllocationmanager() locationmanager.delegate = self locationmanager.distancefilter = 10.0 locationmanager.desiredaccuracy = kcllocationaccuracynearesttenmeters locationmanager.requestwheninuseauthorization() uiapplication.sharedapplication().cancelalllocalnotifications() nslog("location on supposely") } locationmanager.startupdatinglocation() } else { if locationmanager != nil { locationmanager.stopupdatinglocation() } } } func locationmanager(manager: cllocationmanager!, didupdatelocations locations: [anyobject]!) { var location: cllocation = locations[locations.endindex - 1] as! cllocation self.locationtext.text = location.description } func locationmanager(manager: cllocationmanager!, didfailwitherror error: nserror!) { locationtext.text = "failed error \(error.description)" } }
i have activated in simulator location services , in info.plist added nslocationwheninusagedescription , privacy - location..., nothing happens when toggling switch no feedback on. help??
Comments
Post a Comment