Comparing NSNumbers in Objective C

前端 未结 4 1036
遇见更好的自我
遇见更好的自我 2020-11-30 05:29

I am a beginner at Objective-C and I am a bit confused at this scenario. I have the following code:

if (number1 < number2) {
    NSLog(@\"THE FOLLOWING NU         


        
4条回答
  •  迷失自我
    2020-11-30 06:06

    I assume number1 and number2 are pointers to objects. The < sign is comparing the pointers.

    You need to compare the actual floatValue or doubleValue

    if ([number1 doubleValue] < [number2 doubleValue]) 
    

    ....

提交回复
热议问题