2014-10-03 2 views
0

안녕하세요 친구 저는 uitableview에 json 파일을 구문 분석하는 데 문제가 있습니다. 내 JSON 파일은 다음과 같습니다uitable보기에서 json 파일을 구문 분석 할 수 없습니다.

[ 
    { 
    "id": 1, 
    "type": "Deal Closed", 
    "score": 100, 
    "createdAt": "2014-10-03T08:10:10.000Z", 
    "updatedAt": "2014-10-03T08:10:10.000Z" 
    }, 
    { 
    "id": 2, 
    "type": "Followers", 
    "score": 10, 
    "createdAt": "2014-10-03T08:10:28.000Z", 
    "updatedAt": "2014-10-03T08:10:28.000Z" 
    } 
] 

내 코딩이 여기에있다 ..

static NSString *CellIdentifier = @"Leader";  
NSString *firstname = [[promoArray objectAtIndex:indexPath.row] objectForKey:@"type"]; 
NSString *lastname = [[promoArray objectAtIndex:indexPath.row] objectForKey:@"score"]; 
cell.lblPrice.text=[jsonDict valueForKey:@"type"]; 
cell.lblDesc.text=[jsonDict valueForKey:@"score"]; 

이 exception..while 분석을 던졌습니다. 내가 json 파일에서 Uitable보기 유형 및 점수를 구문 분석해야합니다.

+0

1. 이것은 구문 분석이 아니라 배열이나 사전에서 항목에 액세스하는 것입니다. 2.'firstname'과'lastname'은 결코 사용되지 않습니다. 3. 어떤 라인이 예외를 생성하고 오류 메시지가 발생합니까? 이미 전역 예외 중단 점이 없으면 추가하십시오. – zaph

답변

1

이에 조정 : 더 JSON 없습니다

cell.lblPrice.text=jsonDict[indexPath.row][@"type"]; 
cell.lblDesc.text= jsonDict[indexPath.row][@"score"]; 
+0

json 파일에 더 많은 수의 데이터를 추가하면 작동합니다. – user3427653

+0

예. 작동합니다. 변수 이름이 혼란 스럽습니다. – meda

+0

그런 다음 프로모션 배열을 제거해야합니까? – user3427653

관련 문제