views:

131

answers:

1

I have a navigation stack. In the rootView I initialize the location manager, and I have the proper delegate methods settled. Then I push a view passing the current retrieved location. and everything works well

on the other if I push the view while the location is still loading the position of an eventual better coordinate are not sent automatically and the pushed view need to be popped and repushed . How do I retrieve the uploaded coordinates without pop-push again?

A: 

You can add a method like -updateWithLocation: in each controller that needs updating and then call it in your location manager delegate (for controller that is currently on top). If you use UINavigationController you can easily access your top controller using its topViewController property.

Vladimir
Thanks, I'll try right now... back soon
giampo
it works! thanks !!!
giampo
you are welcome :)
Vladimir
Maybe I can ask also: from one side I've to add an -updateWithLocation : in each controllers if I'm not checking that the topViewController is the one that effectively need updating. Is there a simpler way than the if check?from the other ( I apologize for my ignorance) I got a warning because xcode doesn't know that the topViewController has that method really implemented (not a problem, but I don't like warnings)
giampo
I do check that the following way:if ([topController respondsToSelector:@selector(updateWithLocation:)]) [topController performSelector:@selector(updateWithLocation:) withObject:newLocation];performSelector call does not generate a compiler warning
Vladimir
Thanks again!! I was using isKindOfClass to check the controller but this is much much more better. I'm kind of new in this business and I'm still not used to think the right way. Thanks!
giampo