I have a very weird situation.
I am using AppDelegate like this:
appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
and save different values there to share among the application.
e.g
@property (nonatomic, retain) NSString *campaignTitle;
I the user opened the application for the first time – I can assign values to the properties and change them even a few time during the application lifecycle.
e.g.
appDelegate.campaignTitle = theTitle;
However, if the user clicked on home button, and then re-opend the application, if I try to assign new values – the appDelegate values are not changed and stay with the old ones.
What is wrong?
You can’t use AppDelegate this way. It isn’t designed as a persistent store.
If the data being saved is only small then you should be using NSUserDefaults to save it. For anything more complex you should be using CoreData.
Secondly, you shouldn’t be using the AppDelegate to store global data at all. It’s much better practise to use a separate singleton class to store this type of information. You can then encapsulate the get and set methods of the data to put them into the NSUserDefaults for you.
i.e.