Re: Storing preferenses
Re: Storing preferenses
- Subject: Re: Storing preferenses
- From: Óscar Morales Vivó <email@hidden>
- Date: Tue, 7 Oct 2003 12:22:18 +0200
I really don't know what's going wrong, but I can tell your solution is
unnecessarily complex.
Search the docs for NSUserDefaults, get an example or two from the web,
and be very happy.
Hope that helps ;o)
On 6 Oct 2003, at 23:56, Eivind Andersen wrote:
Hi!
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, and add the objects that I wish to
save, using the setObject:forKey: method. After that I write the
dictionary to file using: [prefs
writeToFile:[@"~/Library/Preferences/My Client.plist"
stringByExpandingTildeInPath]
atomically: TRUE];
In awakeFormNib i read from this file by using: prefs = [NSDictionary
dictionaryWithContentsOfFile:
[@"~/Library/Preferences/My Client.plist"
stringByExpandingTildeInPath]];
...and take out the various objects with [prefs objectForKey:@"key"]
When I try to extract the buddylist, I use [[[prefs
objectForKey:@"Buddies"]mutableCopy]retain]
but the result is an emtpy array! The array isn4t empty when I (try to)
write it to file!
What am I doing wrong? Can I store and extract an NSMutableArray in
this way?
Best regards,
Eivind Andersen
_______________________________________________
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.
_______________________________________________
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.