2015-07-11 46 views
-2

如何填充这个NSDictionary数据到UITableView 我想从快译通如何填充这个NSDictionary中的数据到UITableView的

2015-07-11 13:19:50.972 demo[1226:23659] { 
posts =  (
      { 
     post =    { 
      id = 1; 
      "school_id" = 1; 
      subject = Math; 
     }; 
    }, 
      { 
     post =    { 
      id = 2; 
      "school_id" = 1; 
      subject = Science; 
     }; 
    }, 
      { 
     post =    { 
      id = 3; 
      "school_id" = 1; 
      subject = English; 
     }; 
    }, 
      { 
     post =    { 
      id = 5; 
      "school_id" = 1; 
      subject = Hindi; 
     }; 
    }, 
      { 
     post =    { 
      id = 29; 
      "school_id" = 1; 
      subject = Biology; 
     }; 
    } 
); 
} 
+0

答案plz ..... – user3189586

+0

除非你开始提供更多关于你想要达到的目标的解释,并且展示你迄今为止所尝试的 - 反对票和关闭标志,否则你不会得到任何有用的答案。 – luk2302

+0

看到有人已经回答我的问题,并且知道它解决了我的问题。如果你不想给出答案,那么你为什么阅读这个问题。如果你不能解决这个问题,那么你很容易,那么你不受欢迎。你知道这个评论之后有人会投票,但是我不会以任何方式伤害我,因为我将创建另一个帐户,我将得到4分作为开始.try解决问题我是新的在ios这种方式我不能是如此特定的点在我的问题 – user3189586

回答

0

尝试这种方式来获得

- (UITableViewCell *)tableView:(UITableView *)tableView 
    cellForRowAtIndexPath:(NSIndexPath *)indexPath 

方法获取数据出来数据来自字典

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    // if you use custom cell then use this way code 
    FriendSelectionCell *cell = [tableView dequeueReusableCellWithIdentifier:@"friendSelectionCell"]; 
    // get value from dictionary 
    cell.yourlabel.text=[[[[self.dict objectForKey:@"posts"] objectAtIndex:indexPath.row] objectForKey:@"post"] objectForKey:@"id"]; 
    return cell; 
} 
+0

谢谢你Dharmesh – user3189586

+0

你可以使用稍微更现代的语法来访问字典和数组:'self.dict [@“posts”] [indexPath.row] [@“post”] [@“id”]' – quantumkid