Objective-C: NSMutableString error
I keep getting an error with this code, the app is telling me I am trying to mutate an object which is not mutable. Can someone take a look and explain what I am doing wrong? Thanks.
thisrow = [NSString stringWithFormat:@"%i", startPointX2];
NSMutableString* setCoordStr = [[NSMutableString alloc] init];
[setCoordStr appendFormat: thisrow];
if(w==1) {
thiscol = [NSString stringWithFormat:@"%i", endPointY];
[setCoordStr insertString:thiscol atIndex:[setCoordStr length]];
} else {
for(startPointY; startPointY<endPointY+1; startPointY++) 开发者_开发问答{
thiscol = [NSString stringWithFormat:@"%i", startPointY];
[setCoordStr insertString:thiscol atIndex:[setCoordStr length]];
}
}
NSLog(@"%@ ", setCoordStr);
You could used appendString:
instead of your first appendFormat:
and your insertString:atIndex:
精彩评论