Programming Reference/Librarys
Question & Answer
Q&A is closed
- (BOOL)isEqualToNumber:(NSNumber *)number;
Returns a Boolean value that indicates whether the receiver and a given number are equal.
NSNumber *myBoolNumberYES = [NSNumber numberWithBool:YES]; NSNumber *myBoolNumberNO = [NSNumber numberWithBool:NO]; NSNumber *myIntNumber2_a = [NSNumber numberWithInt:2]; NSNumber *myIntNumber2_b = [NSNumber numberWithFloat:2.0]; if ([myBoolNumberNO isEqualToNumber:myBoolNumberYES]) { NSLog(@"NUMBERS WITH BOOL ARE EQUAL!"); } else { NSLog(@"NUMBERS WITH BOOL ARE NOT EQUAL!"); } if ([myIntNumber2_a isEqualToNumber: myIntNumber2_b]) { NSLog(@"NUMBERS WITH INT ARE EQUAL!"); } else { NSLog(@"NUMBERS WITH INT ARE NOT EQUAL!"); }
2012-05-29 00:03:42.197 NSNumberSample[395:f803] NUMBERS WITH BOOL ARE NOT EQUAL!
2012-05-29 00:03:42.199 NSNumberSample[395:f803] NUMBERS WITH INT ARE EQUAL!