• 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: [Solved]registering Defaults with NSUserDefaults not working
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Solved]registering Defaults with NSUserDefaults not working


  • Subject: Re: [Solved]registering Defaults with NSUserDefaults not working
  • From: Gustavo Pizano <email@hidden>
  • Date: Mon, 1 Mar 2010 19:48:26 +0100

Ok I have finished with the defaults things, I think I got desperate after the first step which was setting the Application defaults, and I didn't realize I needed to complete the second step which is allow the user to set his/defaults, so  after I did so,, all was fine, the .plist in the library was created properly and all tis working like a  a charm.

Thanks

Gustavo


On Mar 1, 2010, at 4:47 PM, Gustavo Pizano wrote:

>
> On Mar 1, 2010, at 4:07 PM, Keary Suska wrote:
>
>> On Mar 1, 2010, at 3:01 AM, Gustavo Pizano wrote:
>>
>>> [[NSUserDefaults standardUserDefaults] registerDefaults:appDefaults];
>>> if([[NSUserDefaults standardUserDefaults] synchronize])NSLog(@"Could Save");
>>
>> -registerDefaults: does not actually change default values, it simply sets what the default values should be in certain cases. You can read NSUserDefaultsController about ways to use default values. If you delete your plist preference file, then re-run, you might see different results. You might be happier in the long wrong if you follow the docs and have all of your application defaults in app delegate's +initialize, or as a pre-defined plist in your project. You also don't need to call -synchronize if your app will terminate normally (saving defaults is one of the exit functions).
>>
> Well I did as the Apple example I mentioned, they where doing that in the applicationDidFinishLaunch. Nevertheless,  so .. I have my .plist in the resources with all the values of the colors for the gradients, so from there is where Im reading to create the defaults gradients and I want to save them into the userDefaults,  then when the User click the preferences menu item he/she can choose different colors, then I will generate internally the new gradients  then use the [[NSUserDefaults standarUSerDefaults] setObjectForKey:kGradientKey]. If the user click the button restore defaults I will generate the defaults values form the .plist I have in the resources folder, and again set the gradient data.
>
> I deleted the com.mycompany.myapp, reloaded the application and no files are generated again, shall i run it on release mode?.. :S.
>
> So I will put this bunch of code on the +initialize, and Check the NSUserDefaultsController, so see what other ideas it will give me as you suggested.
>
> Thanks for the help
>
> Gustavo
>
>
>> HTH,
>>
>> Keary Suska
>> Esoteritech, Inc.
>> "Demystifying technology for your home or business"
>>
>

_______________________________________________

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

References: 
 >registering Defaults with NSUserDefaults not working (From: Gustavo Pizano <email@hidden>)
 >Re: registering Defaults with NSUserDefaults not working (From: Keary Suska <email@hidden>)
 >Re: registering Defaults with NSUserDefaults not working (From: Gustavo Pizano <email@hidden>)

  • Prev by Date: Re: Customize UIBarButtonItem
  • Next by Date: Re: NSMenu problems
  • Previous by thread: Re: registering Defaults with NSUserDefaults not working
  • Next by thread: Re: Core Data - synchronize ManagedObjectContexts - save date
  • Index(es):
    • Date
    • Thread