开发者

Objective-C: NSMutableString error

开发者 https://www.devze.com 2023-01-25 03:43 出处:网络
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.

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:

0

精彩评论

暂无评论...
验证码 换一张
取 消