2013-03-31 3 views
0

사용자 정의 셀에로드 할 변수에 계속 액세스하는 데 문제가 있습니다. InSeasonCell이라는 xib, .h, .m이 있습니다. IBOutlet InSeasonCell * _cell이 있습니다. .h의 rootviewcontroller에 있습니다. 내 productAtIndex 값에 액세스 할 때 lldb 오류가 발생합니다. 어떤 도움이라도 좋을 것입니다. Table View 프로그래밍 가이드를 읽으라고했습니다.iOS : 사용자 정의 셀 lldb 메모리 액세스 오류

은 내가 rootviewcontroller에서 초기화하지만 제품의 개체를 채 웁니다 타 객체에 전달

_dataController = [[InSeasonProductDataController alloc] init]; 

을 만들 수 있습니다.

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    static NSString *CellIdentifier = @"InSeasonCell"; 

    InSeasonCell *cell = (InSeasonCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
    if (cell == nil) { 
     [[NSBundle mainBundle] loadNibNamed:CellIdentifier owner:self options:nil]; 
     cell = _cell; 
     _cell = nil; 
    } 
    if(_dataController!=nil){ 
     Product *productAtIndex = [_dataController objectInListAtIndex:indexPath.row]; 
     // Configure the cell... 
      cell.name.text = productAtIndex.name; 
      cell.week.text = productAtIndex.week; 
      cell.image.image = productAtIndex.image; 
    } 

    return cell; 
} 

나는 나의 코드를보고 내가 다른 하나 개의 클래스에서 생성 된 객체를 전달하고 있음을 발견했다. 예를 들면 :

-(id)initWithDataController:(InSeasonProductDataController *)dataController spinner:  (UIActivityIndicatorView *)spinner{ 
     if(self = [super init]){ 
      _dataController = [dataController retain]; 
      _spinner = [spinner retain]; 
     } 
     return self; 
} 

_dataController은이 방법의 뒷부분에서 제품 객체로 채워 도착 및 해제됩니다. 당신이하는 .m 파일에 가지고

+0

이미 답변을 수락 한 이전 질문 인 http://stackoverflow.com/questions/15726970/ios-lldb-exc-bad-access-custom-cell과 어떻게 다른가요? –

+0

'registerNib : ... '를 사용하면 커스텀 테이블 뷰 셀을로드하는 데 훨씬 쉬운 방법이라는 것에주의하십시오. http://stackoverflow.com/a/15591474/1187415. –

+0

확인. 고맙습니다. 한번보세요. – wwjdm

답변

0

알아 냈습니다. My Product 객체는 전달 된 각 변수에 대해 복사본을 만들어야하는 초기화 된 변수를 반환합니다. 이렇게하면 lldb 오류가 제거됩니다.

0

는 세포 프로토 타입 및 속성 검사에 XIB 파일을 클릭에 필요한이 오류를 해결하기> 식별자 (I는 "세포"를 적어) 같은 이름을 삽입 : 방법

:

  • (있는 UITableViewCell *)를 tableView (jQuery과 *)를 tableView cellForRowAtIndexPath (NSIndexPath *) indexPath { ....... 셀 =있는 tableView dequeueReusableCellWithIdentifier @ "셀"]; Cell = [[MainCustomCell alloc] initWithStyle : UITableViewCellStyleDefault reuseIdentifier : @ "셀"];
+0

나는 그것이 오류라고 생각하지 않는다. – wwjdm

관련 문제