2014-07-18 4 views
-5

XML 구문 분석을 사용하고 fetchedobj라는 배열에 내 값을 저장합니다. 이제 배열 fetchedobj의 값을 UILabel에 표시하려고합니다.NSArray 값을 UILabel로 설정하는 방법

5 개의 UILabels이 있으며 5 개의 UILabels에 5 개의 값이 표시되기를 원합니다. 다음을 클릭에 값이 증가되어야하며 UILabels는 마지막 사람의 세부 사항이 UILabels에 표시되는이 코드를 사용하여 다섯 개 값

for (i=0; i<fetchedobj.count;) 
    { 
     n1.text=[[fetchedobj objectAtIndex:i]valueForKey:@"tag"]; 
     n2.text=[[fetchedobj objectAtIndex:i]valueForKey:@"person"]; 
     n3.text=[[fetchedobj objectAtIndex:i]valueForKey:@"place"]; 
     n4.text=[[fetchedobj objectAtIndex:i]valueForKey:@"gENDER"]; 
     n5.text=[[fetchedobj objectAtIndex:i]valueForKey:@"ph"]; 



     i++; 
    } 

의 다음 세트로 업데이트해야합니다. plz help

답변

-1

질문을 올바르게 받아들이면이 작업을 수행 할 수 있습니다. 먼저 전역 NSInteger 변수를 만들고 viewDidLoad()에서 0으로 지정하십시오. (즉, currentIndex = 0). 그리고 이것을 사용하십시오

-(IBAction)btnClicked:(id)sender 
{ 
    currentIndex = currentIndex + 1; 
    if(currentIndex >[fetchedobj count]-1) 
      currentIndex = 0; 

    // here set your values 
    n1.text=[[fetchedobj objectAtIndex: currentIndex]valueForKey:@"tag"]; 
    ----- 
    ----- 
} 
+0

아래의 이유를 게시하십시오. – Yogendra

관련 문제