Я пытаюсь передать значения ячейке таблицы, но когда я заменяю строку userdata.title , она отображается пустым. userdata - объект другого класса UserData, который является внешним, и я импортировал его. Доступ к UserData осуществляется из всех представлений, чтобы передавать объекты с одного контроллера на другой. Теперь, как передать значение таблице и как ее сохранить, если я решит добавить больше значений через мое текстовое поле?Передача данных в ячейки таблицы
- (void)viewDidLoad
{
tabledata = [[NSMutableArray alloc] initWithObjects:@"hello", nil];
tablesubtitles = [[NSMutableArray alloc] initWithObjects:@"hello", nil];
[super viewDidLoad];
//if I use "userdata.title" in replacemnent of @"hello" above, the table show up blank
//self.navigationItem.rightBarButtonItem = self.editButtonItem;
}
//--------------------------------------
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section;
{
return [tabledata count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
{
UITableViewCell *cell = nil;
cell = [tableView dequeueReusableCellWithIdentifier:@"homeworkcell"];
if(cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"homeworkcell"];
}
cell.textLabel.text = [tabledata objectAtIndex:indexPath.row];
cell.detailTextLabel.text = [tablesubtitles objectAtIndex:indexPath.row];
cell.textLabel.font = [UIFont systemFontOfSize:14.0];
//static NSString *CellIdentifier = @"Cell";
/* if (cell == nil) {
cell = [[UITableViewCell alloc]
initWithStyle:UITableViewCellStyleSubtitle
reuseIdentifier:CellIdentifier];
}*/
// Configure the cell.
//-----------------------------------------START----------------------------Set image of cell----
cellImage = [UIImage imageNamed:@"checkboxblank.png"];
cell.imageView.image = cellImage;
//--------------------------------------------END---------------------------end set image of cell--
return cell;
}
Как вы передаете данные пользователю этого класса? – beryllium
#import "UserData.h", затем UserData * userdata; – user1191343
Это не пропуск, это просто импорт заголовков. Где вы его создаете, init и setup в качестве источника данных для таблицы? – beryllium