I have 5 animal objects and i trying to save it in a NSMutableDIctionary. However, according to my code below, only the last animal gets saved in the NSMutableDIctionary.
I don't think i am looping it correctly.
for(int i = 0; i < animalCount; i++) {
[allContacts setObject:name forKey:@"name"];
[allContacts setObject:age forKey:@"age"];
[allContacts setObject:gender forKey:@"gender"];
}
The output of the above displays as follows: (Only the last animal object gets displayed)
{
name = fish;
age = 6;
gender = "female";
}
How i want is that, all five animal objects to be saved in the NSMutableDIctionary so i can display them in a UITableView.
{
name = "cow";
age = 4;
gender = "male";
},
{
name = "dog";
age = 15;
gender = "male";
},
{
name = "fish";
age = 6;
gender = "female";
}