I have been practicing with tableViews but I cannot figure out how to insert new items when a button is clicked.
This is what I have:
BIDViewControlle
You're on the right track. Make sure you're setting your delegate and data source correctly and your outlet is wired to the button.
Edit: Also fairly certain you can't just @"blah" strings into a mutable array. Try initializing the text as an NSString first, and then pass it in as a pointer.
You are doing it right,
- (IBAction)addItems:(id)sender {
// I thought it was as simple as this, but it doesn't work
[self.names addObject:@"Brad"];
[self.tableView relaodData];
}
is the correct way.
Please double check the variable tableView, I can't see the declaration of it.
make sure you have,
@property(weak, nonatomic) IBOutlet UITableView *tableView;
[self.tableView setDelegate:self];
[self.tableView setDataSource:self];
and properly connected the tableView to .nib