Some time ago, I read that comparing version numbers can be done using the following code snippet:
NSString *vesrion_1 = @\"1.2.1\";
NSString *version_2 = @\
Using NSNumericSearch works in most cases but it fails when version formats are different;
e.g. when comparing
[self compareBundleVersion:@"1.1.12" withBundleVersion:@"1.2"];
it will return NSOrderedDescending while it should return NSOrderedAscending.
Please have a look at my NSString category compareToVersion which handles this in a nice way;
[@"1.2.2.4" compareToVersion:@"1.2.2.5"];
There are also a few helpers;
[@"1.2.2.4" isOlderThanVersion:@"1.2.2.5"];
[@"1.2.2.4" isNewerThanVersion:@"1.2.2.5"];
[@"1.2.2.4" isEqualToVersion:@"1.2.2.5"];
[@"1.2.2.4" isEqualOrOlderThanVersion:@"1.2.2.5"];
[@"1.2.2.4" isEqualOrNewerThanVersion:@"1.2.2.5"];
Check it out at; https://github.com/stijnster/NSString-compareToVersion