-1

So, in my previous question (check out this > If-else: NSString) I've known how to check two strings. But now my task is compare two numbers.

isEqualToNumber isn't I need. For example: if the first number has a value 13, the second value has a value 20. How to compare these numbers?

Thank you everyone. Which method do I should use?

My code:

    NSNumber *foo1 = @13;
    NSNumber *foo2 = @14;

I need to compare them:

if ( foo1 < foo2) {
    //some actions
}
Community
  • 1
  • 1
useboot
  • 67
  • 1
  • 5

1 Answers1

6
 if ([foo1 compare:foo2] == NSOrderedAscending) { ... some actions ... }
bbum
  • 162,346
  • 23
  • 271
  • 359