我有一个应用程序,我想将字符串 0..9 显示为秒,将 10 个 ownwords 显示为秒。我采用字符串长度来实现此目的,但它总是给我长度为 2,即使是 0。 .9 或 10 个 ownwords.naturally 它需要给出 1 和 2 但我不明白为什么会出现这种奇怪的行为,我将字符串视为这样`
todaysdateString1= [NSString stringWithFormat:@"%2ld",seconds];
int myLength2 = [todaysdateString1 length];
NSString *subtitle;
NSLog(@"%@",todaysdateString1);
NSLog(@"%d",myLength2);
if(myLength2==2)
subtitle = [NSString stringWithString:@"second"];
else
subtitle = [NSString stringWithString:@"seconds"];
todaysdateString1 = [todaysdateString1 stringByAppendingFormat:@" %@",subtitle];
‘有人能帮帮我吗?