カスタマイズされたセルのリストを表示するTableView(クラスListeExercice)を実装しています。これらのセルは別のクラス(クラスExerciceTableCell)で定義されています。
ListeExerciceクラスでは、viewDidLoadメソッドで次のようにNSArrayを作成します。
table1 = [NSArray arrayWithObjects:@"exo1", @"exo2", nil];
table2 = [NSArray arrayWithObjects:@"10:00", @"10:00", nil];
次に、同じクラスで、テーブル内のセルを表示するためにすべてを実行します
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection(NSInteger)section
- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView
私が得た問題は、基本的に正しいセルを表示するためのコードが配置されている次のメソッドで発生します。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *exerciceTableIdentifier = @"ExerciceTableCell";
ExerciceTableCell *cell = (ExerciceTableCell *)[tableView dequeueReusableCellWithIdentifier:exerciceTableIdentifier];
if (cell == nil)
{
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"ExerciceTableCell" owner:self options:nil];
cell = [nib objectAtIndex:0];
}
//label1 is a label from the cell defined in the ExerciceTableCell class.
cell.label1.text = [tableIntituleExercice objectAtIndex:indexPath.row];
return cell;
}
問題は、これら2つの行の間に競合が発生したことです。
cell = [nib objectAtIndex:0];
と
cell.Label1.text = [table1 objectAtIndex:indexPath.row];
どうやら、2つの「objectAtIndex」の間に競合があります。警告はなく、アプリがクラッシュするだけで、「スレッド1:EXC_BAD_ACCESS(code = 1 ....)」というスレッドが表示されます。
私に何ができるかについて何かアドバイスはありますか?