Re: plist Problem
Re: plist Problem
- Subject: Re: plist Problem
- From: Dave Thorup <email@hidden>
- Date: Fri, 25 Jul 2003 13:11:09 -0600
On 7/25/03 7:26 AM, "publiclook" <email@hidden> wrote:
>
Defaults are normally read once at start-up and cached in memory after
>
that. There are options to force an application to reload defaults.
>
>
On Friday, July 25, 2003, at 03:21 AM, email@hidden wrote:
>
>
> App A is supposed to save a file to the path in the plist. If I run
>
> app A and save a file, it saves it at the correct location. But if I
>
> run app A, then run app B to change the path, app A still saves the
>
> file in the old path. I checked the plist and it has changed, and
>
> whenever app A saves a file, it reads the plist. So how can it still
>
> be using the old path?
>
>
>
> If I quit app A, then run it again, it will save it in the correct
>
> path. Any ideas?
So it sounds like you're using NSUserDefaults, is that correct? In that
case whenever app A saves a file you should "synchronize" the defaults
before you read from them. Example (warning typed in Mail, test first):
----------------------------
// You've probably already done this somewhere
NSUserDefautls* defaults = [NSUserDefaults standardUserDefaults];
...
// now before you read the path and save, you must synchronize
// with the changes that have been made by app B
NSString* path;
[defaults synchronize];
path = [defaults objectForKey:@"The save path"];
// now save the file
----------------------------
<plug type="shameless">
I've got a great little utility called Defaults Manager that lets you easily
view, edit, add, remove, and backup your user defaults. It's very helpful
when developing your application and testing your code that uses
NSUserDefaults.
http://www.kuwan.net/defaultsmanager
</plug>
____________________________________
Dave Thorup
Software Engineer
email@hidden
www.kuwan.net
Defaults Manager - The premier editor for Mac OS X's User Defaults /
Preferences database.
_______________________________________________
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.