Skip navigation.
 
mlRe: how do I determine if this is the first time the app is launched?
FROM : Gregory Weston
DATE : Sun Jun 25 13:13:52 2006

Alan Smith wrote:

> I tried checking if the preference file existed but apparently but by
> the time it awakeFromNib it is there. I need to add some things to the
> defaults so that the rest of my app can use them. I also don't want to
> overwrite them every time is launches, that would defeat the purpose.


I think you probably want to look at the registerDefaults: method of 
NSUserDefaults. This can be used in two ways to achieve what seems to 
be your goal.

1) To do what you actually asked, use register defaults to set up a 
flag indicating that your app has run, and make it false. Then in 
your awakeFromNib check that flag and if it's false set up all you 
like and set the flag to true.

2) Or just use registerDefaults: to set up those values you want the 
rest of the app to be able to use in the first place and forget about 
the "first-run?" notion.

<http://developer.apple.com/documentation/Cocoa/Reference/Foundation/
Classes/NSUserDefaults_Class/Reference/Reference.html#//apple_ref/occ/
instm/NSUserDefaults/registerDefaults:
>

Related mailsAuthorDate
No related mails found.