我想知道为什么我们可以这样声明NSString:
NSString *strongName = @"Kuba";
但我们不能以相同的方式声明NSMutableString:
NSMutableString *strongName2 = @"Kuba";
相反,我不得不使用旧的(?(方法:
NSMutableString *strongName3 = [NSMutableString stringWithFormat:@"Kuba"];
感谢您的任何有意义的见解:(
NSString *myString = @"Kuba"
是单独NSString
的简写。如果您需要一个NSMutableString
,您可以从中获得一个可变副本:NSMutableString *myMutableString = [@"Kuba" mutableCopy]
。