我是Objective-C的初学者,在这种情况下我有些困惑。我有以下代码:
if (number1 < number2) {
NSLog(@"THE FOLLOWING NUMBER ");
NSLog(@"%@", number1);
NSLog(@"IS LESS THAN");
NSLog(@"%@", number2);
}
当我运行此代码时,我看到的确是这样的奇怪结果:
2011-07-06 20:38:18.044 helloworld[1014:207] THE FOLLOWING NUMBER
2011-07-06 20:38:18.047 helloworld[1014:207] 190.8776
2011-07-06 20:38:18.050 helloworld[1014:207] IS LESS THAN
2011-07-06 20:38:18.053 helloworld[1014:207] 96.75866
这两个数字都是NSNumber对象,怎么会这样呢?我通过查找屏幕上精灵之间的距离来获得两个数字。
任何线索或建议将不胜感激
NSLog
使用NSLog(@"THE NUMBER %@ IS LESS THAN %@", number1, number2);