我收到此错误:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Attempt to mutate immutable object with replaceCharactersInRange:withString:'
但我无法弄清楚我正在变异的不可变对象。
NSRange subRange = [self.label.text rangeOfString: @"="];
int numA = 5;
int numB = 3;
NSMutableString *mixed = [NSString stringWithFormat: @"%i %i", numA, numB];
NSMutableString *string = [NSString stringWithString: self.label.text];
subRange = [string rangeOfString: @"="];
if (subRange.location != NSNotFound)
[string replaceCharactersInRange:subRange withString:mixed];