Note that there are some explanatory texts on larger screens.

plurals
  1. POConflict between a tableView index and NSArray objectAtIndex
    primarykey
    data
    text
    <p>I'm implementing a TableView (class ListeExercice), showing a list of customized cells. These cells are defined in another class (class ExerciceTableCell). </p> <p>In the class ListeExercice, I do create an NSArray as follow in the viewDidLoad method:</p> <pre><code>table1 = [NSArray arrayWithObjects:@"exo1", @"exo2", nil]; table2 = [NSArray arrayWithObjects:@"10:00", @"10:00", nil]; </code></pre> <p>Then in the same class, I do everything in order to display the cells in the table</p> <pre><code>- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection(NSInteger)section - (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView </code></pre> <p>The problem I got happens ins the following method, basically where the code in order to display the right cell is located : </p> <pre><code>- (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; </code></pre> <p>}</p> <p>The problem is that I got a conflict between these 2 lines: </p> <pre><code>cell = [nib objectAtIndex:0]; </code></pre> <p>and </p> <pre><code>cell.Label1.text = [table1 objectAtIndex:indexPath.row]; </code></pre> <p>Apparently there is a conflict between the 2 "objectAtIndex". I do not have any warning, just an App crash, and a thread saying "Thread 1 : EXC_BAD_ACCESS (code = 1 ....)</p> <p>Any advice on what I could do?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload