开发者

How I do to call a nib file at only first launch of my application?

I'm new here but I'd like to learn very well iPhone SDK...

I'm making an iPhone 开发者_Python百科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!


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.


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.


I'd like to use NSUserDefaults...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜