【问题标题】:Unexpected result of insertString method of NSMuttableStringNSMuttableString 的 insertString 方法的意外结果
【发布时间】:2014-01-29 10:20:44
【问题描述】:

代码很简单。

NSMutableString *tfContent = [[NSMutableString alloc] init];
for (int i = 0; i<4; i++) {
    [tfContent  insertString:@"ę́" atIndex:i];
    NSLog(@"%@",tfContent);
}

预期结果:

ę́
ę́ę́
ę́ę́ę́
ę́ę́ę́ę́

但它给出的结果是

ę́
ęę́́
ęęę́́́
ęęęę́́́́

这里有什么问题?

【问题讨论】:

  • 这些空格是如何进入可变字符串的?
  • 这是我的错误。现在我编辑了问题。

标签: ios7 nsstring special-characters nsmutablestring


【解决方案1】:

试试这个:

NSMutableString *tfContent = [[NSMutableString alloc] init];

for (int i = 0; i<4; i++) {

     [tfContent appendString:@"ę́"];

      NSLog(@"%@",tfContent);
}

你会得到预期的输出。

【讨论】:

    猜你喜欢
    • 2015-03-24
    • 2023-03-14
    • 2012-02-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多