Changing an NSToolbar Identifier
Changing an NSToolbar Identifier
- Subject: Changing an NSToolbar Identifier
- From: Matthias Arndt <email@hidden>
- Date: Fri, 2 Oct 2009 06:53:34 +0200
Hi Markus,
The background for this is as follows: I have a new version of an
application that shares its app ID with the previous version. The
toolbar in question is saving its state (using the "Autosaves
configuration" setting in IB). The new version introduces
additional items that are visible in its default setup. However, if
the previous version saved a toolbar configuration, those would not
show up because the toolbar ID is the same and it would load the old
config.
when I ran into the some problem a couple of weeks ago I decided to
take another approach:
I introduced a new key in user defaults reflecting the "toolbar
version". If the toolbar version stored in the user defaults doesn't
match the toolbar version of the application I simply delete the old
plist settings and the application will display the default set of the
new toolbar. The code is placed in "applicationDidFinishLaunching" of
the application controller:
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSString *toolbarVersion = [defaults stringForKey:@"ToolbarVersion"];
if (![toolbarVersion isEqual:@"2.0"])
{
[defaults removeObjectForKey:@"NSToolbar Configuration 130D8E5D-
C86E-47DD-9A4E-B367517DA148"];
[defaults setObject:@"2.0" forKey:@"ToolbarVersion"];
}
For me this approach seems to be rough and it'll break if someone
switches back to the older version. Unfortunately I had no better
idea, but I'm open to suggestions ... Too bad the IB doesn't allow to
set toolbar IDs.
Matthias
_______________________________________________
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