I need to get the user's app version number and compare it with the current app version on my server. If the user's app version is lower, then he will get a pop-up to update his app. While doing this, I need to compare the version of the app with the versions that are available. How can I compare the strings which are in the format "2.0.1"
and "2.0.09"
and get the highest one, in Objective-C?
How about using the compare:options:
method of the NSString class?
NSString *v1 = @"2.0.1";
NSString *v2 = @"2.1";
NSComparisonResult result = [v1 compare:v2 options:NSNumericSearch];
if (result == NSOrderedSame || result == NSOrderedDescending) {
// do
} else {
// do
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With