我想使用appendFormat将字符串附加到NSMutableString,插入空格以获得字符串的最小长度.
在objective-c中,我刚刚使用过
[text.mutableString appendFormat:@"%-12s", "MyString"];
Run Code Online (Sandbox Code Playgroud)
我会的
"MyString "
Run Code Online (Sandbox Code Playgroud)
但在斯威夫特,我试过了
text.mutableString.appendFormat("%-12s", "MyString")
Run Code Online (Sandbox Code Playgroud)
我得到了一切,但不是"MyString".它似乎是一些随机字符,我不知道它来自哪里.
有没有人知道为什么会这样,我该怎么办?
感谢你们!