/ / NSFetchedResultsController zwraca obiekty z atrybutami null - obiektyw-c, ios, cocoa-touch, core-data

NSFetchedResultsController zwraca obiekty z atrybutami null - cel-c, ios, cocoa-touch, dane podstawowe

Więc używam urządzenia Mogenerator z Core Data, theresultsController zwraca dobre obiekty z prawidłowymi atrybutami, gdy po raz pierwszy ładuję widok tabeli. Ale kiedy przewijam tabelę, wszystkie przeładowane komórki są wypełniane obiektami o atrybutach pustych zwracanych z resultsController. Czy to jakiś problem z pamięcią podręczną?

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

static NSString *CellIdentifier = @"Cell";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}

// Configure the cell...
Log *log = [self.resultsController objectAtIndexPath:indexPath];
cell.textLabel.text = [NSString stringWithFormat:@"%@", log.text];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;

return cell;
}

Odpowiedzi:

0 dla odpowiedzi № 1

Okazuje się, że nie powinienem umieszczać wyników resultsController w viewWillLoad lub viewDidLoad. Umieściłem go we własnej metodzie dostępu i działa teraz poprawnie.