• 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: NSUserDefaults and NSArray
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSUserDefaults and NSArray


  • Subject: Re: NSUserDefaults and NSArray
  • From: jerome LAURENS <email@hidden>
  • Date: Mon, 16 Sep 2002 13:12:20 +0200

Le vendredi 13 septembre 2002, ` 03:47 PM, j o a r a icrit :

> Have you verified that you actually find anything in user defaults?
> Something like this:
>
> - (void) readMyArray
> {
> NSArray * myArray = [[NSUserDefaults standardUserDefaults]
> objectForKey: @"MyArray"];
>
> if (myArray != nil) {
> NSLog(@"Found %d entries in user defaults", [myArray count]);
> } else {
> NSLog(@"Nothing stored in user defaults");
> }
> }
>
>


this is exactly the kind of problems registerDefaults is made for
Before asking the user defaults for some info, you should register basic
values that make your code consistent

in some +(void)initialize method, put something like

[[NSUserDefaults standardUserDefaults] registerDefaults:
[NSDictionary dictionaryWithObject: [your basic array] forKey:
@"MyArray"]];

then when asking

myArray = [[NSUserDefaults standardUserDefaults] objectForKey:
@"MyArray"]

If there is no object for key @"MyArray" in the user database, [your
basic array] will be returnd instead.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: NSUserDefaults and NSArray (From: j o a r <email@hidden>)

  • Prev by Date: Re: Get default Browser and Mail Client
  • Next by Date: Applescript Studio Examples - Currency Conv. - SOAP?
  • Previous by thread: Re: NSUserDefaults and NSArray
  • Next by thread: Re: NSUserDefaults and NSArray
  • Index(es):
    • Date
    • Thread