如何在 NSString 前面添加前导空格?
我需要字符串的长度始终为 5... 例如,如果
我传递 hello"
,我会得到 "hello"
我通过 "xml"
,我得到 " xml"
(“xml”之前有两个空格);
我通过 "i"
,得到 " i"
(“i”之前有四个空格)。
最有效的方法是什么?谢谢。
I need the String always have length 5...
for example, if
I pass hello"
, I get "hello"
I pass "xml"
, I get " xml"
(two spaces before "xml");
I pass "i"
, I get " i"
(four spaces before "i").
What is the most efficient way to do it? Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我想这可能会有所帮助:
I suppose this might help:
//现在你可以使用yourString了。它已经格式化了。
//now you can use yourString .it is formatted.