2014-07-18 42 views
-5

我使用xml解析并将我的值存储在数组中,名为fetchedobj。现在我想要将数组fetchedobj中的值显示给UILabel。如何设置NSArray值为UILabel

有五个UILabels,并点击一个按钮,我想要五个值显示在五个UILabels上。在下次点击值将递增,并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帮助

回答

-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