当我将字符串附加到NSMutableString
using时appendString:
,出现以下错误:
Terminating app due to uncaught exception 'NSInvalidArgumentException',
reason: 'Attempt to mutate immutable object with appendString:'
我的代码是:
self.partialWord = [NSMutableString stringWithCapacity:self.wordLength];
for (int i=0; i<wordLength; i++) {
[self.partialWord appendString:@"-"];
}
在我的头文件中:
@property (copy, nonatomic, readwrite) NSMutableString *partialWord;
我不明白为什么它说对象是不可变的,因为它是一个NSMutableString
. 为什么[self.partialWord appendString:@"-"];
零件不起作用?