I want to store a value something like 3.2.7 in Numbers in iOS, coz I want to compare the value with other.
Is there any data type is available? or any tricks?
anyone have a solution for this?
I want to store a value something like 3.2.7 in Numbers in iOS, coz I want to compare the value with other.
Is there any data type is available? or any tricks?
anyone have a solution for this?
matt
On
This is almost certainly a duplicate of Compare version numbers in Objective-C.
As the accepted answer there tells you, strings like @"3.2.1" and @"2.3.7" are strings, not numbers — but they can be compared in the intuitively numeric way as version strings, by calling compare:options: with the NSNumericSearch option.
And if that doesn't quite satisfy your needs, other answers provide many useful tweaks to the comparison algorithm.
Copyright © 2021 Jogjafile Inc.
If you wanted to implement something like that in Swift you could probably get away with something like the following: