原问题来自于CSDN问答频道,更多解决方案见:http://ask.csdn.net/questions/2335问题描述:NSArray中有如下数据。使用AFHTTPRequestOperation来获取结果,然后执行 [ListOfName addObject:[responseData valueForKey:name]];,想要下面的结果显示在tableView中,但是不知道怎么实现?
(
        (
        "Richard Conover",
        "Richard Conover",
        "Kaitlyn Matheson",
        "Andrea Wannemaker",
        "Andrea Wannemaker",
        test,
        james,
        test,
        gaurav,
        sdfsdfs
    )
)如果用NSArray.count返回。如何在tableView中分开打印?解决方案:1.设置UITableView的delegate,datasource
self.tableView.delegate=self;
self.tableView.datasource=self;2.实现协议方法-(NSInteger)numberOfSectionsInTableView {
     return 1;
}-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection {
      return [ListOfName count];
}-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
     static NSString *identifier=@"cellIdentifier";
     UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:identifier];
    if (cell==nil) {
          cell=[[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier] autorelease];
    }    cell.textLabel.text=[ListObName objectAtIndex:[indexPath row]];
}