使用单位数整数形成两位数字字符串 [英] Make a two-digit string from a single-digit integer

查看:178
本文介绍了使用单位数整数形成两位数字字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果整数小于10,我如何在aa字符串中使用两位整数?

How can I have a two-digit integer in a a string, even if the integer is less than 10?

[NSString stringWithFormat:@"%d", 1] //should be @"01"


推荐答案

我相信stringWithFormat说明符是标准的 IEEE printf specifiers 。您尝试过

I believe that the stringWithFormat specifiers are the standard IEEE printf specifiers. Have you tried

[NSString stringWithFormat:@"%02d", 1];

这篇关于使用单位数整数形成两位数字字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆