かなり基本的なcellForRowAtIndexPathの実装。
なぜアナライザーがここでメモリリークしていると言っているのか疑問に思います。
- (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];
}
MyObject *object = [[self.datasource objectForKey:key] objectAtIndex:indexPath.row];
cell.textLabel.text = object.title;
return cell;
}
アナライザーは、「セル」が潜在的にリークしていることを教えてくれます。これはアナライザーの単なる弱点ですか、それともこれをどのように処理する必要がありますか?
注:次のように自動リリースの呼び出しを追加します。
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier] autorelease];
クラッシュを引き起こします。何かご意見は?