ios - When close view that started locations service notification error occure -


i have created small app use project it's core:
https://github.com/dsdavids/ttlocationhandler
, worked fine until have moved stating location services view in app.

what app doing: when started can tap on start button , (in emulator locations must enabled) on map route of movement displayed move.
problem came when moved starting action in second view.
in second view want start location service , close it.
problem when start locating on second view error (application crash exc_bad) here:

ttlocationhandler ... dispatch_async(dispatch_get_main_queue(), ^{         if (output_logs) nslog(@"sending notification out");         nsnotification *anotification = [nsnotification notificationwithname:locationhandlerdidupdatelocation object:[locationtosave copy]];         [[nsnotificationcenter defaultcenter] postnotification:anotification];     }); ... 

i think because close second view (view started service) , ttlocationhandler still tries send something.
better understanding problem have added project @ git hub:
https://github.com/1110/common-location-features

you can download , run start service second view , when close view app crash in few seconds.

i thankful if can find little time tell me doing wrong here sure small thing doing wrong.

whole code in secondviewcontroller.m

thanks

the problem location manager sending location updates object no longer exists.

i don't have time dig through of code, speaking once tell location manager startupdatinglocation, need keep location manager delegate object around until tell stop. if refer "second view" delegate object, can't let view deallocated until tell location manager stopupdatinglocation.

generally want have 1 object cllocationmanagerdelegate, , keep object around long need it. delegate notified every time location changes, , delegate's responsibility update views care location.


Comments

Popular posts from this blog

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

php - render data via PDO::FETCH_FUNC vs loop -

The canvas has been tainted by cross-origin data in chrome only -