【问题标题】:Objective C - Using insertString for an NSMutable stringObjective C - 将 insertString 用于 NSMutable 字符串
【发布时间】:2009-07-07 09:49:35
【问题描述】:

对于 NSMutableString,我如何在索引“0”处为名为“a”的 NSMutableString 插入一个“-”符号。现在我的代码如下所示:

a = [insertString: @"-" atIndex: 0];

Xcode 抛出一个错误,指出“insertString”未声明。我的代码看起来很不对劲。请给我指导。

【问题讨论】:

  • 要扩展 @jop 所说的内容,它的 [receiver message (possibly arguments here, arguments are indicated by a : colon)]。在这种情况下,正确的格式是[a /*receiver*/ insertString: /*message*/ @"-" atIndex: 0 */arguments*/]

标签: iphone objective-c cocoa cocoa-touch


【解决方案1】:

把对象放在括号内:

[a insertString: @"-" atIndex: 0];

【讨论】:

    猜你喜欢
    • 2011-01-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-05-17
    • 2015-02-10
    • 2011-05-28
    相关资源
    最近更新 更多