I’m trying to pull my app version from my DB which is 1.2.0 and compare it to the installed apps current version. which may be undefined or lower (e.g. 1.1.0 etc..).
I know I can use isEqualTo on NSString but that just compare’s for equality.
I’d like to know how to use compare for a result similar to Java’s compareTo method which return an integer negative, 0, positive.
I’ve looked up NSComparisonResult but can’t figure out how to use access the results.
Also, on a side note: Is it ok to assume the version previous to the update is lower that update version in apple apps? Is it possible that an app be downgraded so when an app runs the database might belong to a newer version of app?
Thanks.
You can use NSString::compare to compare two NSStrings.
Ex:
Notice that the
retValuehas the result of whether the two strings are equal or not. The defintion of the enumNSComparisonResult–If
retValue == NSOrderedSame, then the two strings are equal. i.e., return value is 0.