I know many people ask this but all the answers are specific apps so I don’t understand how to work it for my app.
tableData = [NSArray arrayWithObjects:@"Chocolate Brownie", @"Mushroom Risotto", nil];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection: (NSInteger)section
{
return [tableData count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *simpleTableIdentifier = @"SimpleTableItem";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableIdentifier];
}
cell.textLabel.text = [tableData objectAtIndex:indexPath.row];
return cell;`
}
the reason being ut
tableDatavariable is not retained and you have assigned it via factory method with is already autoreleased.in .h file, make it retain property and use this variable with self. in ur code.
in .m,
then use it like:
now you wont get any error as tableData is now retained.
do not forget to release it in
deallocif you are not using ARC.