On 27 May '08, at 9:16 AM, Jeff LaMarche wrote:

Is there any way to make this work with the standard about box, or do
I have to hand-roll one in order to make this work? I'm assuming the
latter, but figured I'd ask just in case; I hate reinventing the wheel.

I've done this for a client before, __DATE__ and __TIME__ work fine, just clean and build the project before delivery (which you'd do anyway) to ensure they're current.

And no need to hand-roll an About box! Just disconnect the About menu from -orderFrontStandardAboutPanel and connect it to your own action method that calls -orderFrontStandardAboutPanelWithOptions:. That's all the normal method does, except you'll add some options to override default display strings; any you ignore take the usual values.

It's not infinitely flexible, but it's easy to customize the basic panel with only a few lines of code.

- (IBAction)showCustomAboutPanel:(id)sender
{
NSString *compileDate = [NSString stringWithCString:__DATE__ encoding:NSASCIIStringEncoding];

NSString *compileTime = [NSString stringWithCString:__TIME__ encoding:NSASCIIStringEncoding];
        // would normally run these through a formatter to internationalize
        
        // grab the default value for About Panel's @"Version" key
        // from plist. Could be "build nnnn", "0.2a7" etc.
NSString *buildVersion = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"];
        
        // result is "buildVersion, date, time"
NSString *displayString = [NSString stringWithFormat:@"%@, %@, %@", buildVersion, compileDate, compileTime];

        // override default short version string
NSDictionary *optionsDictionary = [NSDictionary dictionaryWithObjectsAndKeys:displayString, @"Version", nil];
        
        // Final appearance depends on value of
        // CFBundleShortVersionString in plist,
        // and/or key @"ApplicationVersion" in
        // options dictionary.
        //
        // If @"ApplicationVersion" key is added,
        // CFBundleShortVersionString is ignored.
        // For a key value of "DEMO VERSION",
        // About panel will display
        //   "DEMO VERSION (nnnn, date, time)"
        //
        // If @"ApplicationVersion" key is not added,
        // CFBundleShortVersionString in plist
        // will be used, if it exists.
        // For a value of "x.x", About will display
        //   "Version x.x (buildVersion, date, time)"
        // For a value of "WhizBang '08", About will
        // omit the word "Version" and display
        //   "WhizBang '08 (buildVersion, date, time)"
        //
        // If CFBundleShortVersionString does not
        // exist, About displays
        //   "Version (buildVersion, date, time)"
        
        [NSApp orderFrontStandardAboutPanelWithOptions:optionsDictionary];
}

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to