Re: Using version number in code
Re: Using version number in code
- Subject: Re: Using version number in code
- From: glenn andreas <email@hidden>
- Date: Fri, 21 Oct 2011 11:26:58 -0500
Or better use [[NSBundle mainBundle] objectForInfoDictionaryKey: <key>] since that will localize it if possible, which is important if you are presenting it to the user (unlikely that the short version will be localized, but the long one might be)
On Oct 21, 2011, at 10:59 AM, Martin Hewitson wrote:
> Chris,
>
> You can get those values like this:
>
> NSDictionary *infodict = [[NSBundle mainBundle] infoDictionary];
> NSString *bundleVersion = [dict valueForKey:@"CFBundleVersion"];
> NSString *shortVersion = [dict valueForKey:@"CFBundleShortVersionString"];
> CGFloat ver = [shortVersion floatValue];
>
> Cheers,
>
> Martin
>
> On Oct 21, 2011, at 04:54 PM, Chris Paveglio wrote:
>
>> In an app's Info.plist there are the 2 values for Bundle Version. Is there a way to use those directly in a class, in code? For example, I often like to put the version number of an app in the title bar or in part of the window (I mostly develop in-house for my company so UI standards can suit our needs, users can see immediately if it's the newest version). So far I've simply made a variable or set the version number directly (as a string) in my AppDelegate class, but if I could somehow use the Bundle Version or Bundle Version String Short that would be great. Any suggestions?
>> Chris
>> _______________________________________________
>>
>> 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
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> Martin Hewitson
> Albert-Einstein-Institut
> Max-Planck-Institut fuer
> Gravitationsphysik und Universitaet Hannover
> Callinstr. 38, 30167 Hannover, Germany
> Tel: +49-511-762-17121, Fax: +49-511-762-5861
> E-Mail: email@hidden
> WWW: http://www.aei.mpg.de/~hewitson
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
>
>
>
>
> _______________________________________________
>
> 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
Glenn Andreas email@hidden
The most merciful thing in the world ... is the inability of the human mind to correlate all its contents - HPL
_______________________________________________
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