2013-06-13 3 views
0

최근에 "Programming Without XIB 's"로 전환하고 Custom TableView 셀에 문제가 있습니다. XIB를 사용하는 경우 이전에, 내가 제발 말해 내가프로그래밍 방식의 사용자 지정 셀 메모리 누수 문제

static NSString *CellIdentifier = @"Cell"; 
ConditionReportCustomCell *cell = (ConditionReportCustomCell*)[self.inventoryTableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
if(cell==nil){ 
    cell = [[ConditionReportCustomCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] ; 
} 
return cell; 

을 뭐하는 거지 완벽하게 작동하는 다음 코드

NSString *CellIdentifier = @"Cell"; 
AttachmentCustomCell *cell=(AttachmentCustomCell*)[self.attachmenttableview dequeueReusableCellWithIdentifier:CellIdentifier]; 
if(cell==nil){ 
    NSArray* objects= [[NSBundle mainBundle] loadNibNamed:@"AttachmentCustomCell" owner:nil options:nil]; 
    AttachmentCustomCell *acell = [objects objectAtIndex:0]; 
    cell = acell; 
} 

하지만 지금은 나에게 메모리 누수를 제공합니다 다음을 사용하고를 사용 잘못된. 나는 응용 프로그램의 충돌 결과로 autorelease를 사용하지 못할 것을 압니다.

cell = [[[ConditionReportCustomCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease] ; 
+1

프로에서 ARC를 사용 : –

+0

죄송합니다, 언급하는 것을 잊었습니다. ARC를 사용하지 않고 있습니다. – Shantanu

답변

2

당신은 ARC 단지 오토 릴리즈를 추가 사용하지 않는 경우?
+0

autorelease를 사용하고 싶지 않습니다. autorelease를 사용하면 응용 프로그램이 충돌합니다. 다른 해결책? – Shantanu

+1

@shantanu ... 충돌이 발생합니까? 어딘가에 다른 문제가 있습니다. 올바른 방법은 자동 기록을 사용하는 것입니다. 여기 ... 당신은 다른 곳에있는 세포를 방출하고 있습니까? – meronix

+0

"다른 해결책이 있습니까?"... 코드 유출, 유일한 방법은 충돌하는 경우 릴리스하는 것입니다, 그것은 아마 당신이 코드의 다른 부분에 릴리스하는 것을 의미합니다 ... – meronix