Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在将一个字符串转换为 NSnumber,但是当我这样做时,数字左侧的零被省略了。例如,当我将字符串转换为 Nsnumber 时,字符串为“09”,它变为 9。如何让 xcode 将 09 表示为 NSnumber?
修改其字符串表示:
#import <Foundation/Foundation.h> int main(int argc, char *argv[]) { @autoreleasepool { NSNumber *i = @9; NSString *s = [NSString stringWithFormat:@"%02d", i.intValue]; NSLog(@"%@",s); } }