tags:

views:

139

answers:

3

Hi all, I'm new here but I'd like to learn very well iPhone SDK...
I'm making an iPhone app where I'd like to show a modalView controller at launch of my app... How can I do this?
In this modalView, I request some informations and the view must appear only when these informations aren't saved!
Anyone can help me?

P.S.: Sorry for my bad English but I'm Italian... :D Thanks!

A: 

Typically, you check for your saved data and if it's not there, you assume that it is the first run.

Thus, you first need to decide how you are going to persist data:

  1. User defaults (NSUserDefaults).
  2. Store a file. Typically a property list (plist) in the Documents directory.
  3. Core Data.
gerry3
A: 

I'd like to use NSUserDefaults...

Matthew
A: 

First, try to avoid to use NSUserDefautls as it's not application specific and can cause troubles under some circumstances (see reference docs).

I'd suggest to save your app specific data to some plist file for which you can check for at app startup -(void) applicationDidFinishLoading: method of your app delegate class - and decide if your modal view should be shown or not.

Let's say you have application wide accessible NSMutableDictionary instance where you store your preferences. When app is about to quit i.e. - (void) applicationWillTerminate: method of your app delegate, simply store content of that dictionary to plist somewhere under you app directory structure (Documents folder is a good choice). See NSDictionary reference on how to store/read plist files. It's pretty simple.

Matthes