Take the 2-minute tour ×

I have an NSMutableArray named as totalunits. It has some data. Each data has value like this. ({blah blah blah},{blah = 1}).

The second value should change to 0 instead of 1. Thats what I explained in following codes.

NSMutableDictionary *inappDict=[[NSMutableDictionary alloc] init];
    [inappDict setObject:@"0" forKey:@"inapp"];
    [[totalunits objectAtIndex:currenttag] replaceObjectAtIndex:1 withObject:newDict];        

But using this, I'm getting an exception like this:

[__NSCFArray replaceObjectAtIndex:withObject:]: mutating method sent to immutable object.

Help me.

Thanks in advance

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

You've initialized your NSMutableArray as NSArray, so it has no mutation methods; double check, that you need to operation NSMutableArray and not NSArray

share|improve this answer
well, your exception description is telling another stuff =); an array that is returned by the [totalunits objectAtIndex:currenttag] is a NSArray, not a NSMutableArray - just post here a code, which adds items into the totalunits array –  Denis Nov 30 '11 at 12:43
add comment

Your Answer


