Re: Storing preferenses
Re: Storing preferenses
- Subject: Re: Storing preferenses
- From: Nick Zitzmann <email@hidden>
- Date: Tue, 7 Oct 2003 23:04:12 -0700
On Monday, October 6, 2003, at 02:56 PM, Eivind Andersen wrote:
Hi!
Hei.
I4m making a Instant Messaging application, where I would like to store
the my own name, the server address and a list containing all the
"buddies", so I don4t have to type them in every time I start the
application
I4m using a NSMutableDictionary
Why not use NSUserDefaults? That class was made for this sort of
thing...
When I try to extract the buddylist, I use [[[prefs
objectForKey:@"Buddies"]mutableCopy]retain]
You don't need to retain a mutable copy, unless you are intentionally
bumping its retain count for some reason... If you're not intentionally
doing this, then you'll have a memory leak.
but the result is an emtpy array! The array isn4t empty when I (try to)
write it to file!
This is why you should be using NSUserDefaults - because even if your
application doesn't use it, AppKit does store some of its own defaults
in NSUserDefaults (like window frames, etc.), and NSUserDefaults is
most likely overwriting the dictionary the app just saved just saved,
if your application's bundle identifier and the "preferences file" +
.plist are the same.
Nick Zitzmann
AIM/iChat: dragonsdontsleep
Check out my software page:
http://seiryu.home.comcast.net/
"I have always wished that my computer would be as easy to use as my
telephone. My wish has come true. I no longer know how to use my
telephone." - Bjarne Stroustrup
_______________________________________________
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.