i have an application in which i am trying to create an nsmutablearray of dictionaries.all are working fine but the problem is only the last element is adding in count times of the coredata array.here is how i am doing it `
rateValues=[[NSMutableArray alloc]init];
rateValues1=[[NSMutableDictionary alloc]init];
if(messagesArray!=nil)
{
for (Messagestable *rating in messagesArray)
{
//[rateValues addObject:rating.message];
[rateValues1 setObject:rating.fromid forKey:@"fromid"];
[rateValues1 setObject:rating.toid forKey:@"toid"];
[rateValues1 setObject:rating.sendingtime forKey:@"sendingtime"];
[rateValues1 setObject:rating.message forKey:@"message"];
[rateValues1 setObject:rating.fromname forKey:@"fromname"];
[rateValues addObject:rateValues1];
}
}
else{
//NSLog(@"array empty");
return;
}
NSLog(@"%@",rateValues);
`my array is contaning only the last element 4 times.ie it is the count of the data in coredata.Can anybody help me?
You need to create a new dictionary each iteration; what you are currently doing is overwriting your single dictionary and re-adding it to the array.