2012-06-18 4 views
0

나는 배열을 가지고,속보 배열,

MutableArray (
     { 
     "a" = 1; 
     "b" = ""; 
     "c" = " "; 
     "imagepath" = "../images/image.png"; 
     "d" = "dummy text"; 
     "e" = 2; 
     "f" = "dummy text"; 
     "g" = dummy text; 
     "h" = dummy text; 
     "i" = "Feb 19, 2010"; 
    }, 
     { 
     "a" = 2; 
     "b" = "dummy"; 
     "c" = "dummy"; 
     "imagepath" = "../images/noimage.png"; 
     "d" = "dummy text"; 
     "e" = 3; 
     "f" = "dummy text"; 
     "g" = dummy text; 
     "h" = dummy text; 
     "i" = "Mar 23 , 2010"; 
    }) 

정확히 어떤 내가하려하는 것은

row 1 : Title a, 
row 2 : Title b, 
row 3 : title c, 

처럼 배열에서 별도로 값을 얻을 수 있습니다 아래 같은 나는 각각의 값을 원하는 별도로 배열에서.

이미지와 라벨이 이미 만들어진 테이블보기, 맞춤 셀이 있습니다. 예 행 1 = 인덱스 1의 데이터 행 2 = 인덱스 2의 데이터 그런 식으로. 배열에서 값을 분리하여 테이블 행의 레이블에 넣는 방법을 모르겠습니다.

어떻게 제안 할 수 있습니까?

+0

을하지만 유 하시겠습니까 그것을 분리하십시오. [array count]를 섹션으로 사용하고 dict = [array objectAtIndex : section.indexPath]와 같이 섹션에 따라 데이터를 채 웁니다. –

+0

cell.lblNm.text = 1 행의 인덱스 1과 같이 행 레이블을 동적으로 채우려 고합니다. – FirstTimer

답변

1

//

//이 붙여 넣기 KVC

를 사용하여 값 점점 시도 - (있는 UITableViewCell *)있는 tableView를 (jQuery과 *)있는 tableView cellForRowAtIndexPath : (NSIndexPath *) indexPath

id key; 
    NSDictionary *theDictionary = [yourMutableArray objectAtIndex:indexPath.row]; 
    id value; 
    for (key in [theDictionary allKeys]) 
    { 
     value = [theDictionary objectForKey:key]; 
     // do something with the value 
    NSLog(@"key: %@, value: %@", key, [theDictionary objectForKey:key]); 
    } 
Or else Try this 

NSDictionary *theDictionary = [yourMutableArray objectAtIndex:indexPath.row]; 
NSLog(@"key: a, value: %@", , [theDictionary objectForKey:@"a"]); 
NSLog(@"key: b, value: %@", , [theDictionary objectForKey:@"b"]); 
NSLog(@"key: c, value: %@", , [theDictionary objectForKey:@"c"]); 
// So on ... 
1

배열 인 경우 tableView를 만들 때 cellForRowAtIndexPath 메서드 내에서 [objectAtIndex : indexPath.row]를 사용하지 않는 이유는 무엇입니까? 또한 셀 객체를 만들고 배열에 해당 객체의 배열을 만든 다음 그 값을 가져올 수 있습니다.

+0

cell.lblNm.text = 예를 설정하려면 ex? 내가 어떻게 할 수있는 ? – FirstTimer

+0

NSArray * array = [mutableArrayName objectAtIndex : IndexPath.row], 다음 cell.lblNm.text = (NSString *) [array objectAtIndex : indexThatTheleTitleIsAt]; – CBredlow

+0

사실 그것은 가변 배열입니다. – FirstTimer