0

In my case, I have two NSString values. First one is Current_version and second one is Last_version. Current_version & Last_version value came from my html file. This 2 string contains value like this:

  • Last_version = 1.0.2
  • Current_version = 1.0.9

I want to convert value without losing any data. Now I want to display those version which are greater then last_version.

So I want to compare these two values.

halfer
  • 19,824
  • 17
  • 99
  • 186
Yogendra Patel
  • 813
  • 2
  • 8
  • 24
  • 1
    These are not double (there are "two points"). You need to compare each part : major/minor/patch one by one. If `NSString *last_version = @"1.0.2";`, you can use `NSArray *lastVersionComponents = [last_version componentsSeparatedByString:@"."];` (same for current_version), and check `[lastVersionComponents[i] integerValue]` vs `[currentVersionCompoents[i] integerValue]`, where i in our case is 0, 1 or 2. – Larme Oct 27 '16 at 12:14

1 Answers1

-2
NSString *lastVersionString = [Last_version stringByReplacingOccurrencesOfString:@"." withString:@""];
NSString *newVersionString =[Current_version stringByReplacingOccurrencesOfString:@"." withString:@""];
float current = [newVersionString floatValue];
float old = [lastVersionString floatValue];
Matloob Hasnain
  • 1,025
  • 6
  • 21