Now that we have NSNumber literals with compiler support in Objective-C, is there a preferred way to compare an NSNumber to a known integer value?
The old way is
[myNumber integerValue] == 5
Now we can do [myNumber isEqualToNumber:@5]
or even [myNumber isEqualToNumber:@(someVariable)]
.
Is there an advantage to the isEqualToNumber:
method, or should we stick with integerValue unless the value to compare to is already an NSNumber?
One advantage I can see is if someVariable changes from an NSInteger to a CGFloat, no code changes will be needed for the new way.