I have some external variables defined in a Global.h header and included in some of my views to easily work on some small data.
After applicationWillEnterForeground
gets fired to bring the app up, I have setup a function which asks for an NSURLConnection
to update some api data which might have changed while the app was away. Then I update some of the vars accordingly.
All this happens in AppDelegate
then I call an NSNotificationCenter
to update a label which displays this var in MainController.m The Notification works, the method is called but the var has the previous value.
The strange thing is that although the var is updated (I can see it in log, using debugger and moving step by step) in the ViewController it still has the old value and it messes up my calculations.
The var is not declared at all in MainController.m so it isn't a local instance.
If the app is not gone to background and then up, everything is working as expected, which makes me thing that something in the saved instance of MainController is causing the issue.
Any ideas on that?
Ok, stupidity revisited.
I WAS actually declaring the var in AppDelegate which made it a local one so the global kept it's previous value correctly in MainController After removing the references in AppDelegate.h and AppDelegate.m it worked as it should.