Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Help with NSUserDefaults

Help with NSUserDefaults
Thread Tools
Senior User
Join Date: Feb 2003
Location: USA
Status: Offline
Reply With Quote
Apr 24, 2005, 04:04 PM
 
OK, I'm quite comfortable with Cocoa/ObjC, but up to this point I have not made use of the defaults system. I am already reading and writing to the standard user defaults, so I'm off to a good start.
My question is: When someone runs the app for the first time obviously the defaults plist doesn't exist yet. I'm assuming there's a way to check for the existence of the file, and if not provide a default set of preferences. I've browsed some sample code and have some ideas but wondered how you all handle this situation. Thanks!
MacBook 2.0 160/2GB/SuperDrive
Lots of older Macs
     
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status: Offline
Reply With Quote
Apr 24, 2005, 04:40 PM
 
There's no need for you to check for the existence of any files. Use registerDefaults: to register the values that you want to be there if the user hasn't set anything.
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
     
Senior User
Join Date: Feb 2003
Location: USA
Status: Offline
Reply With Quote
Apr 24, 2005, 04:55 PM
 
Thanks, I was just reading about registerDefaults when I checked the forum. Appreciate it!
MacBook 2.0 160/2GB/SuperDrive
Lots of older Macs
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 07:26 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2