Re: NSToolbar: notification of change?
Re: NSToolbar: notification of change?
- Subject: Re: NSToolbar: notification of change?
- From: Andy Lee <email@hidden>
- Date: Tue, 02 Jun 2009 02:06:30 -0400
On Jun 2, 2009, at 12:02 AM, Andy Lee wrote:
Dunno if this would work, but... how about doing
setAutosavesConfiguration:YES and observing user defaults?
Whoops, just noticed this:
On Jun 1, 2009, at 11:06 PM, David Reitter wrote:
[Also we don't use the NS defaults system due to cross-platform
maintenance requirements, so we need to implement persistency, even
though this doesn't have to be synchronously of course.]
That's unfortunate, because this seems to work:
In awakeFromNib:
NSString *defaultsKeyPathForToolbarItems =
[NSString stringWithFormat:@"NSToolbar Configuration %@.TB
Item Identifiers",
[myToolbar identifier]];
[[[NSUserDefaultsController sharedUserDefaultsController] defaults]
addObserver:self
forKeyPath:defaultsKeyPathForToolbarItems
options:0
context:NULL];
Then:
- (void) observeValueForKeyPath: (NSString *) keyPath
ofObject: (id) object
change: (NSDictionary *) change
context: (void *) context
{
NSLog(@"toolbar items are now %@", [[myToolbar items]
valueForKey:@"itemIdentifier"]);
}
Maybe there's some way you can use the NSUserDefaults mechanism just
for this, and ignore its persistence?
--Andy
_______________________________________________
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