ios - Can't Determine When User Doesn't Allow Location Services -


i'm requesting user turn on location services. want know when user clicks don't allow can handle notifications. however, didfailwitherror or didchangeauthorizationstatus methods not being called when click don't allow. know nothing printed in logger. i've attached code sample. doing wrong , how fix this. thanks.

import uikit  import corelocation  class awesomeviewcontroller: uiviewcontroller, cllocationmanagerdelegate {      let locationmanager = cllocationmanager()      override func viewdidload() {         super.viewdidload()          let authorizationstatus = cllocationmanager.authorizationstatus()          if(authorizationstatus == .authorizedwheninuse || authorizationstatus == .authorizedalways) {             // authorization         } else {             locationmanager.requestwheninuseauthorization()         }     }       func locationmanager(manager: cllocationmanager!, didchangeauthorizationstatus status: clauthorizationstatus) {         print(status)     }      func locationmanager(manager: cllocationmanager!, didfailwitherror error: nserror!) {                     print(error.localizeddescription)     } } 

the didfailwitherror or didchangeauthorizationstatus methods not being called

those delegate methods. location manager not have delegate - not have you (the awesomeviewcontroller instance) delegate. not going call methods, ever. need set location manager's delegate (in case set self).


Comments