开发者

NSString stringWithFormat with tabs instead of spaces

开发者 https://www.devze.com 2023-03-23 19:07 出处:网络
You can see that I add 40 spaces after my string but it starts at index开发者_Go百科 0. Can I do the same thing with tab \"\\t\" instead of spaces \" \"?

You can see that I add 40 spaces after my string but it starts at index开发者_Go百科 0. Can I do the same thing with tab "\t" instead of spaces " "?

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];
0

精彩评论

暂无评论...
验证码 换一张
取 消