[futurebasic] Re: [FB] Software version check

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : October 2014 : Group Archive : Group : All Groups

From: Brian S <fblistserve@...>
Date: Wed, 8 Oct 2014 16:41:01 -0700
Robert wrote:

> 3.10.0
> 
> vs 
> 
> 3.9.10
> 
> if numeric:
> 
> 3110 // lower but newer
> 
> vs
> 
> 3910 // older, but higher

Assuming compliance with Apple’s numbering system ( expected on MAS i.e. Major.minor.bugfix ) is important, consider cycling through the number a node at a time and check. Whenever a node is found not equal, use that for the comparison.  For example:

1. check the first node:   3 is equal to 3, so go to the second node
2. 9 is less than  10 and a difference has been found and the loop for the final node could be exited. If the comparison was instead 3.10.2 to 3.10.3 this node would detect 10 equal to 10 and move on to the final node where 3 would be compared to 2.

Download the version # ( with fullstops/periods ) into a string or array and parse into its pieces: major, minor and full stop.

NSArray *majorMinorBugFix = [yourDownloadedString componentsSeparatedByString:@"."];  // put pieces in an array
Now your major is in majorMinorBugFix[0], minor in majorMinorBugFix[1] and bug fix in majorMinorBugFix[2]
Loop through the array and apply the logic described above.

btw: on a slightly tangential note, when I check OS X release ( which I don’t anymore because there are better methods in Objective-C ), the first node is ignored ( 10 ) and only the second node is checked ( i.e. 6,7,8,9,10 ) because OS X release number can present the same problem Robert describes with a higher release number ( i.e. 1010 being lower than a lower release number - 1094 when the periods are removed )


Brian