简体   繁体   中英

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.
Also, your line could be a bit more simple :

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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