Alternatives to type casting when formatting NS(U)Integer on 32 and 64 bit architectures?

前端 未结 3 1832
粉色の甜心
粉色の甜心 2020-12-12 13:39

With the 64 bit version of iOS we can\'t use %d and %u anymore to format NSInteger and NSUInteger. Because for 64 bit tho

3条回答
  •  北荒
    北荒 (楼主)
    2020-12-12 14:29

    I prefer to just use an NSNumber instead:

    NSInteger myInteger = 3;
    NSLog(@"%@", @(myInteger));
    

    This does not work in all situations, but I've replaced most of my NS(U)Integer formatting with the above.

提交回复
热议问题