How to add an object to array?
I'm using an NSMutableArray to populate cells in my tableview. The problem
is, when I try adding an object to my array, it replaces all the objects
with the one that was added so I always only have 1 object in my array.
Because of this, my tableview always has one cell that is just overwritten
whenever the below method is called. Am I missing something?
_selectedThingArray = [[NSMutableArray alloc] init];
_currentThing = newThing;
//Note: newThing is the object being passed when this method is called.
//It is the new data that will should passed into the cell.
[_selectedThingArray addObject:_currentThing];
NSLog(@"%@", newThing);
NSLog(@"array: %@", _selectedThingArray);
[self.tableView reloadData];
No comments:
Post a Comment