【发布时间】:2010-08-10 21:14:10
【问题描述】:
我有这个 UITableView 应用程序,一个基本的日记应用程序,在这个方法中 XCode 说我有内存泄漏。建议开始泄漏的第一行是 117 "NSString *CellIdentifier"。 到 if (cell ==..., 到 Diary *diaryEntry, 到 NSString *stringDate. 它声明该方法返回一个拥有 +1 保留计数的对象。 我试图释放单元格,stringDate...没有什么能改变这个事实,那么我在想什么/做错了什么?
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
// A date formatter for the time stamp static
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
}
Diary *diaryEntry = [diaryArray objectAtIndex:indexPath.row];
cell.textLabel.text = diaryEntry.diaryTitle;
NSString *stringDate = [[DiaryDateFormatter alloc] convertDateToString:[diaryEntry diaryDate]];
cell.detailTextLabel.text = stringDate;
[stringDate release];
return cell;
}
【问题讨论】:
标签: objective-c iphone