以前說過的int float long 等等 都是oc中的基本數據類型 他們都不是對象 可是 有時候 咱們須要將這些值做爲對象使用spa
這時候 咱們能夠使用NSNumber類來存儲基本數據類型code
if([num1 isEqualToNumber:num2]){ }
switch ([num1 compare:num2]) { case NSOrderedAscending: //num1 小於 num2 break; case NSOrderedSame: //num1 等於 num2 break; case NSOrderedDescending: //num1 大於 num2 break; default: break; }
---------------> numberWithInt 和 numberWithInteger使用差異orm
【1】使用numberWithInt方法建立一個整型數,須要使用intValue來獲取他的值,使用%i做爲格式化字符串對象
【2】使用numberWithInteger方法建立整型數,須要使用integerValue來獲取他的值,也能夠轉換成long或者使用stringWithFormat將他格式化爲字符串 使用%li做爲格式化字符串字符串