我有這個UITableView應用程序,一個基本的日記應用程序,在這個方法XCode說我有內存泄漏。建議首先泄漏的第一行是117「NSString * CellIdentifier」。 下來如果(細胞== ...,日記* diaryEntry,NSString *字符串日期。 那裏它說明方法返回一個+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;
}
我終於弄清楚了,到了它覺得這樣的年齡。但是現在我已經殺死了那個covertDateToSting的東西。剛剛造成了問題。在那之後問題解決了。 – 2010-08-11 06:09:10