简体   繁体   English

NSString stringWithFormat,带有制表符而不是空格

[英]NSString stringWithFormat with tabs instead of spaces

你可以看到我在我的字符串之后添加了40个空格,但它从索引0开始。我可以用标签“\\ t”而不是空格“”来做同样的事吗?

NSString *firstString = [[NSString stringWithFormat:@"%@",stringToWrite] stringByPaddingToLength:40 withString:@" " startingAtIndex:0];

Yes @"\\t" will put tab instead of spaces. @"\\t"将使用制表符而不是空格。
Also, your line could be a bit more simple : 此外,您的行可能会更简单:

NSString *firstString = [stringToWrite stringByPaddingToLength:40
                                                    withString:@" "
                                               startingAtIndex:0];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM