Hi I am using below line of code,where both of my responseJson and indexpathArray are NSmutableArrays
[responseJson addObject:indexpathArray];
but I m getting
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[__NSCFArray insertObject:atIndex:]: mutating method sent to immutable object'
I have referred related topics Getting "mutating method sent to immutable object" error but still the same
Actually here I am trying to append records from new array to old array where I am Getting 10 records every time from server.
Any help is appreciated!
update
NSMutableArray *arrayResult = [NSMutableArray arrayWithArray:responseJson];
// Now add objects top arrayResult
[arrayResult addObject:finalarray];
NSLog(@" arrayResult before ::: %@",arrayResult);
responseJson = [[NSMutableArray alloc]initWithArray:arrayResult];//carshing here now
update:
- (void)saveNearMeData:(id)response
{
NSArray *finalarray1 = [[NSMutableArray alloc]init];
NSMutableArray = [response valueForKey:@"Deals"];
indexpathArray = [[NSMutableArray alloc]initWithArray:finalarray1];
NSLog(@" finalarray before ::: %@",finalarray1);
if(responseJson.count>0){
NSMutableArray *arrayResult = [[NSMutableArray alloc]initWithArray:responseJson];;
// Now add objects top arrayResult
[arrayResult addObject:finalarray];
NSLog(@" arrayResult before ::: %@",arrayResult);
responseJson = arrayResult;
}else{
responseJson = [response valueForKey:@"Deals"];
}
}