In this code from an array i am selecting a dictionary,modifying it and saving back in another array .but i dont know why at the second last line of this code ie where i am inserting the dict it is crashing (message sent to deallocated instance).how can i fix this

```
        NSArray *array=[NSArray arrayWithContentsOfFile:plistPath];
        NSLog(@"array before %@",array);
        NSMutableArray *tempArray=[[NSMutableArray alloc]init];
        tempArray=(NSMutableArray*)array;
        NSMutableDictionary *dictToBeChanged=[[NSMutableDictionary alloc]init];
        dictToBeChanged=[tempArray objectAtIndex:indexPath.row];
        [dictToBeChanged setObject:[NSNumber numberWithBool:YES] forKey:@"isPaid"];
        [tempArray removeObjectAtIndex:indexPath.row];
        [tempArray insertObject:dictToBeChanged atIndex:indexPath.row];
        NSLog(@"array after %@",tempArray);

```