2012-05-12 139 views
0

泄漏儀表指向「cell.textLabel.text = str;」作爲內存泄漏。我不知道爲什麼我自動釋放細胞。iOS內存泄漏cellForRowAtIndexPath

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

static NSString *MyIdentifier = @"MyIdentifier"; 

// Try to retrieve from the table view a now-unused cell with the given identifier. 
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier]; 

// If no cell is available, create a new one using the given identifier. 
if (cell == nil) { 
    // Use the default cell style. 
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:MyIdentifier] autorelease]; 
} 

// Set up the cell. 
NSString *str = [array objectAtIndex:indexPath.row]; 
cell.textLabel.text = str; 

return cell; 
} 
+0

後精鑄人的價值是什麼,如果你試圖使用'的NSString *海峽= [NSString stringWithString:[array objectAtIndex:indexPath.row]];'? – Majster

回答

0

你可能沒有釋放您用於獲取Strings.Also數組對象,試圖從陣列中提取作爲

str= [NSString stringWithFormat:"%@",(NSString *)[array objectAtIndex:indexPath.row]];