I have an application which have UIScrollView with Paging .. and it has arrays with images .. What I want to do is saving which array has been viewed last time the app was running and when I open the app again it should show the last array has been viewed.
Thanks in advance!
Tie your array saving code to the
UIApplicationDidEnterBackgroundNotificationnotification, and then tie your loading code to theUIApplicationDidBecomeActiveNotificationnotification.You can also use the appropriate protocol methods in UIApplicationDelegate.
…rereading the question — are you looking for help on how to save something or how to trigger saving at the right time?
Edit
It looks like you’re already following a tutorial with Ray Wenderlich, but I’ll just make a plug for one that I found incredibly simple when I was starting out: http://cocoadevcentral.com/
In terms of saving things to disk, you’ve got several options, the easiest of which is probably to use the NSUserDefaults as another user noted. It’s a dictionary (key : value) system, so you can store your array/image/pathToTheImage, etc. by a name of your choosing, i.e.
“LastImageViewed” : UIImage <–(object) and then load it back by the same name.
Here’s the reference for the NSUserDefaults class: https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSUserDefaults_Class/Reference/Reference.html
and the above mentioned notifications and methods reference:
http://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UIApplicationDelegate_Protocol/Reference/Reference.html#//apple_ref/occ/intf/UIApplicationDelegate
Does that help?