Skip to content

Commit 908b3f9

Browse files
committed
• Added method +[SSYVersionTriplet versionTripletFromBundle:]
• Using that new method, made +[SSYAppInfo calculateUpgradeState] more reliable, because it now gets the current version from the bundle's Info.plist directly instead of NSWorkspace, which may find a different instance of the app with a different version number if more than one instance are installed on the system.
1 parent 269a2ef commit 908b3f9

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

SSYAppInfo.m

+2-2
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ - (void)calculateUpgradeState {
8787
[self setUpgradeState:upgradeState] ;
8888
if ([self upgradeState] != SSYCurrentRev) {
8989
// Get a nice, clean, filtered versionString of the form "major.minor.bugFix" using SSVersionTriplet methods
90-
SSYVersionTriplet* currentVersionTriplet = [SSYVersionTriplet versionTripletFromBundleIdentifier:[[NSBundle mainAppBundle] bundleIdentifier]] ;
90+
SSYVersionTriplet* currentVersionTriplet = [SSYVersionTriplet versionTripletFromBundle:[NSBundle mainAppBundle]] ;
9191
NSString* currentVersionString = [currentVersionTriplet string] ;
9292

9393
// Record currently-launched version into prefs
@@ -124,4 +124,4 @@ + (void)calculateUpgradeState {
124124
}
125125

126126

127-
@end
127+
@end

SSYVersionTriplet.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,16 @@ typedef struct SSYVersionStruct_struct SSYVersionStruct ;
8282
*/
8383
+ (SSYVersionTriplet*)versionTripletFromString:(NSString*)versionString ;
8484

85+
+ (SSYVersionTriplet*)versionTripletFromBundle:(NSBundle*)bundle ;
86+
8587
/*!
8688
@brief Returns an autoreleased version triplet from a bundle
8789
@details Version number string is found as described in
8890
rawVersionTripletFromBundleIdentifier: and then version numbers in triplet are parsed
8991
as described in versionTripletFromString:
9092
9193
@details This function is not reliable because it relies on -rawVersionStringFromBundleIdentifier
92-
which is also not reliable. If you've got the bundle, use +rawVersionStringFromBundle: instead.
94+
which is also not reliable. If you've got the bundle, use +versionTripletFromBundle: instead.
9395
@param bundleIdentifier The bundle identifier of the target bundle
9496
@result An autoreleased version triplet, or nil.
9597
*/

SSYVersionTriplet.m

+6-1
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,11 @@ + (SSYVersionTriplet*)versionTripletFromString:(NSString*)versionString {
7777
return versionTriplet ;
7878
}
7979

80+
+ (SSYVersionTriplet*)versionTripletFromBundle:(NSBundle*)bundle {
81+
NSString* versionString = [self rawVersionStringFromBundle:bundle] ;
82+
return [self versionTripletFromString:versionString] ;
83+
}
84+
8085
+ (SSYVersionTriplet*)versionTripletFromBundleIdentifier:(NSString*)bundleIdentifier {
8186
NSString* versionString = [self rawVersionStringFromBundleIdentifier:bundleIdentifier] ;
8287
return [self versionTripletFromString:versionString] ;
@@ -210,4 +215,4 @@ + (NSString*)cleanVersionStringFromBundleIdentifier:(NSString*)bundleIdentifier
210215
return [vt string] ;
211216
}
212217

213-
@end
218+
@end

0 commit comments

Comments
 (0)