• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: [iPhone] Application running for the very first time...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [iPhone] Application running for the very first time...


  • Subject: Re: [iPhone] Application running for the very first time...
  • From: James Lin <email@hidden>
  • Date: Fri, 2 Oct 2009 13:55:28 +0800


Thank you for the code snipet, but I am confused at the logic here...

the following code will be executed EVERY time the program runs, right?

NSMutableDictionary *dictionary = [[NSMutableDictionary alloc] initWithCapacity:10];
[dictionary setObject: [NSNumber numberWithBool:YES] forKey:@"PIFirstRun"];
[[NSUserDefaults standardUserDefaults] registerDefaults:dictionary];
[dictionary release];

so [dictionary setObject: [NSNumber numberWithBool:YES] forKey:@"PIFirstRun"] will run EVERYTIME the program runs?
Wouldn't that set my PIFirstRun to YES every time the user launch my application?


In that case....

if ([[NSUserDefaults standardUserDefaults] boolForKey:@"PIFirstRun"] == YES){
[[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"PIFirstRun"];
//first run

[userDefaults setInteger:5 forKey:@"myIngeter"];
}


will reset my "myInteger" to 5 EVERY single time?


What if all i want is to set "myInteger" to 5 the very first time my application lunches and ONCE ONLY?


Sorry for the confusion...thanks for help again...

James


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Prev by Date: Re: odd behavior with NSError?
  • Next by Date: Re: [iPhone] Application running for the very first time...
  • Previous by thread: Re: [iPhone] Application running for the very first time...
  • Next by thread: Re: [iPhone] Application running for the very first time...
  • Index(es):
    • Date
    • Thread