2012-06-21 5 views
0

목표 -C에 익숙하지 않아서 다소 어려움을 겪었습니다. 내 앱의 다른 부분에서 사용하고 완벽하게 작동하지만 내 앱의 다른보기에서 사용하면 충돌이 발생합니다. 응용 프로그램, 그리고 임 꽤 확신 내가 같은 방식으로 설정했습니다. 새로 고침하려면 충돌 응용 프로그램

나는 엉망이 코드는 TEH 외형이

NSArray *timesArray = [self.tableDataArray objectAtIndex:2]; 
    NSDictionary *dictionary = [timesArray objectAtIndex:indexPath.row]; 
    cell.timeLabel.text = [dictionary objectForKey:@"time"]; 
    cell.destinationLabel.text = [dictionary objectForKey:@"destination"]; 

있는 NSArray * timesArray가에 정지 무엇 인 코드에 중단 점을 넣어 엑스 코드를 얻었으나, 다른 오류 또는 아무것도가 주어지지 그래서 나는 무엇을 바꾸어야하는지 다소 곤란하다.

편집 번호 1 : 명확한 설명을 위해 삭제 된 이전 편집. 내가 다시 천천히 확인하고, 무슨 일 것이는 데이터의 3 개 완전 파싱을 수행하고, 내가 가진 모든 물건을 출력하므로

EDIT 번호 2

확인.

2012-06-21 13:37:09.148 NextBus[5990:1a603] Array: (
    { 
    routeName = "Oxford West"; 
    routeNumber = 17; 
    stopDirection = Westbound; 
    stopName = "Griffith At Commissioners Sb"; 
    stopNumber = 811; 
}, 
"Next 3 Vehicles Arrive At:", 
    (
      { 
     destination = "To Byron Baseline/Griffith"; 
     time = "1:58 P.M."; 
    }, 
      { 
     destination = "To Byron Baseline/Griffith"; 
     time = "2:15 P.M."; 
    }, 
      { 
     destination = "To Byron Baseline/Griffith"; 
     time = "2:35 P.M."; 
    } 
), 
"Prediction Last Updated 1:37:06 Pm 6/21/2012" 
) 
2012-06-21 13:37:09.148 NextBus[5990:1a603] Array: (
    { 
    routeName = "Oxford West"; 
    routeNumber = 17; 
    stopDirection = Westbound; 
    stopName = "Griffith At Commissioners Sb"; 
    stopNumber = 811; 
}, 
"Next 3 Vehicles Arrive At:", 
    (
      { 
     destination = "To Byron Baseline/Griffith"; 
     time = "1:58 P.M."; 
    }, 
      { 
     destination = "To Byron Baseline/Griffith"; 
     time = "2:15 P.M."; 
    }, 
      { 
     destination = "To Byron Baseline/Griffith"; 
     time = "2:35 P.M."; 
    } 
), 
"Prediction Last Updated 1:37:06 Pm 6/21/2012" 
) 
2012-06-21 13:37:09.149 NextBus[5990:1a603] Array: (
    { 
    routeName = "Oxford West"; 
    routeNumber = 17; 
    stopDirection = Westbound; 
    stopName = "Griffith At Commissioners Sb"; 
    stopNumber = 811; 
}, 
"Next 3 Vehicles Arrive At:", 
    (
      { 
     destination = "To Byron Baseline/Griffith"; 
     time = "1:58 P.M."; 
    }, 
      { 
     destination = "To Byron Baseline/Griffith"; 
     time = "2:15 P.M."; 
    }, 
      { 
     destination = "To Byron Baseline/Griffith"; 
     time = "2:35 P.M."; 
    } 
), 
"Prediction Last Updated 1:37:06 Pm 6/21/2012" 
) 

는 내가 그것을 어떤 이유로, 구문 분석을 중지, 그것은

2012-06-21 13:37:45.590 NextBus[5990:1a603] Array: (
    { 
    routeName = "Oxford West"; 
    routeNumber = 17; 
    stopDirection = Westbound; 
    stopName = "Griffith At Commissioners Sb"; 
    stopNumber = 811; 
} 
) 

를 수행하고 충돌 새로 고침 당기고합니다.

EGO 끌어 오기 새로 고침 키트입니다.

+0

잘못된 행 앞에 NSLog (@ "Array : % @", self.tableDataArray);를 입력하십시오. 무엇이 표시됩니까? –

+0

분명히 알겠지만 뭔가가 호출 사이에'self.tableDataArray'의 내용을 변경해야합니다. (게시 된 코드는'cellForRowAtIndexPath :'에서 나온 것입니다.) –

답변

0

편집 : 어떤 시간은 다음 버스를 사용할 수없는

당신의 쿼리가 예를 들어, 불충분 한 데이터를 반환 할 때 충돌이 발생하는 것 같습니다. 당신이 확인할 수있는 경우, 수정은 간단하다 : 당신은 가능성의 경계를 넘어 배열에 액세스하려고

if ([self.tableDataArray count] > 1) { 
    NSArray *timesArray = [self.tableDataArray objectAtIndex:2]; 
    NSDictionary *dictionary = [timesArray objectAtIndex:indexPath.row]; 
    cell.timeLabel.text = [dictionary objectForKey:@"time"]; 
    cell.destinationLabel.text = [dictionary objectForKey:@"destination"]; 
} else { 
    //-- do something to show that no times are available 
} 

:

NSArray *timesArray = [self.tableDataArray objectAtIndex:2]; 

timesArray

3 개 요소, 다음 프로그램이 충돌이 없어. ..

배열이 채워지는 방식과이 작업에서 기대하는 방식을 검토해야합니다.

편집 : 당신이 당신의 질문에 한 편집을 기반으로

, 당신이 몇 번 게시 된 라인과 마지막 시간 프로그램이 충돌을 실행하는 것 같다. 위에서 알 수 있듯이 첫 번째 반복에서는 배열에 충분한 요소가 채워집니다. 마지막 경우 :

2012-06-21 13:25:03.448 NextBus[5964:1a603] Array: (
{ 
routeName = Springbank; 
routeNumber = 5; 
stopDirection = Eastbound; 
stopName = "Berkshire At Berkshire Place Sb"; 
stopNumber = 2196; 
} 

배열에는 하나의 객체 만 있습니다. 이것은 다르게 취급해야하는 코너 케이스입니까?

+0

이것에 관해서는, 나는 그 정보를 모두 필요로하지 않습니다.보기를 채우고 있습니다. 단지 다음 3 번 버스의 시간을 보여줍니다. 내가 루프를 여러 번 반복했는지 알아. 시간의 인스턴스가 하나만 필요합니다. –

관련 문제