J'ai un UITableViewCell avec une méthode comme celle-ci.Objectif C - UITableViewCell plantant sur le rouleau
-(void) setupStore:(StoreModel *) store {
self.title.text = store.title; // crash here when scrolling
}
Cette méthode est appelée depuis une classe UIViewController qui contient UITableView.
Quelque chose comme ça
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
...
[cell setupStore:[storesArray objectAtIndex:indexPath.row]];
...
}
qui fonctionne lorsque la table d'abord chargé, mais quand je fais défiler la table, il plantage avec EXC_BAD_ACCESS d'erreur.
Qu'est-ce qui pourrait en être la cause?
Veuillez éclairer.
Merci,
T
Vous accédez un objet qui a été désallouée. Pouvez-vous nous montrer comment/où vous définissez la propriété 'storesArray'? – warrenm
Hey warrenm, voici comment je définis storesArray. storesArray = [[[StoresLocations alloc] init] conserve]; Et storesArray est une propriété de UIViewController. Faire un NSLog juste avant d'appeler [cell setupStore: [storesArray objectAtIndex: indexPath.row]]; en fait me donne une valeur. Merci, Tee – teepusink
[[[StoresLocations alloc] init] retain]; est déjà sur-conservé, car alloc/init augmente le reaitnCount avec 1. – vikingosegundo