Почему эти UITableViewCells вызывают утечку в инструментах? - PullRequest
1 голос
/ 18 сентября 2009

Итак, после многих устаревших отладок комментариев, чтобы уменьшить утечку инструментов. Утечка происходит, когда я помещаю новый TableViewController в стек.

Я обнаружил, что получаю утечку из этого кода:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";

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

if(![feedData isFinishedLoading]){
    [[cell textLabel] setText:@"Loading..."];
    [[cell detailTextLabel] setText:@"..."];
}
else{
    NSDictionary *dict = [[feedData items] objectAtIndex:indexPath.row];
    [[cell textLabel] setText:[dict valueForKey:@"title"]];
    [[cell detailTextLabel] setText:[dict valueForKey:@"description"]];
    [cell setAccessoryType:UITableViewCellAccessoryDetailDisclosureButton];
}
return cell;
}

Эта версия не пропускает:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";

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

//  if(![feedData isFinishedLoading]){
//      [[cell textLabel] setText:@"Loading..."];
//      [[cell detailTextLabel] setText:@"..."];
//  }
//  else{
//      NSDictionary *dict = [[feedData items] objectAtIndex:indexPath.row];
//      [[cell textLabel] setText:[dict valueForKey:@"title"]];
//      [[cell detailTextLabel] setText:[dict valueForKey:@"description"]];
//      [cell setAccessoryType:UITableViewCellAccessoryDetailDisclosureButton];
//  }
return cell;
}

Эта версия делает:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";

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

//  if(![feedData isFinishedLoading]){
        [[cell textLabel] setText:@"Loading..."];
        [[cell detailTextLabel] setText:@"..."];
//  }
//  else{
//      NSDictionary *dict = [[feedData items] objectAtIndex:indexPath.row];
//      [[cell textLabel] setText:[dict valueForKey:@"title"]];
//      [[cell detailTextLabel] setText:[dict valueForKey:@"description"]];
//      [cell setAccessoryType:UITableViewCellAccessoryDetailDisclosureButton];
//  }
return cell;
}

Вот крышка экрана инструментов:

http://imgur.com/YR8k8

Проблема в моем коде где-то? Или это ошибка в фреймворке / симуляторе?

1 Ответ

0 голосов
/ 18 сентября 2009

В этом стеке утечек нет ничего, что вызывало бы ваш код, поэтому я не знаю, сможете ли вы от него избавиться. Я знаю, что Большой красный шип страшен, но это всего 16 байтов. Apple не идеальна и, возможно, что-то в их коде делает это. Может быть, вы можете попробовать использовать точки доступа, чтобы посмотреть, поможет ли это

cell.textLabel.text = @"Loading...";
cell.detailTextLabel.ext = @"...";
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...