简体   繁体   English

如何将这种数据显示到UITableview中

[英]How to Display this kind of data into UITableview

I am having NSArray in which it is having following data, i am using AFHTTPRequestOperation which give me result and after that i am doing [ListOfName addObject:[responseData valueForKey:name]]; 我正在使用NSArray,它有以下数据,我正在使用AFHTTPRequestOperation给我结果,之后我正在做[ListOfName addObject:[responseData valueForKey:name]]; and getting following result and that result i want to display in tableview but can understand how to do it becuause i an new to iphone 并获得以下结果和结果我想在tableview中显示,但可以理解如何做到这一点因为我是一个新的iPhone

(
        (
        "Richard Conover",
        "Richard Conover",
        "Kaitlyn Matheson",
        "Andrea Wannemaker",
        "Andrea Wannemaker",
        test,
        james,
        test,
        gaurav,
        sdfsdfs
    )
)

if i do NSArray.count it will return only 1 so how to print it separately in tableview 如果我做NSArray.count它将只返回1,所以如何在tableview中单独打印它

What you want to do is set the TableView datasource to be the first object in that Array (which is another Array ). 您要做的是将TableView数据源设置为该Array的第一个对象(这是另一个Array )。 Something like this: 像这样的东西:

NSArray *myTableViewDataSourceArray = [myOriginalArray objectAtIndex:0];

Then use myTableViewDataSourceArray for the datasource methods of the TableView . 然后使用myTableViewDataSourceArray作为TableView的数据源方法。

As per your structure, you having array with objects which also array. 根据您的结构,您拥有包含对象的数组也是数组。

That means, [ListOfName addObject:[responseData valueForKey:name]]; 这意味着, [ListOfName addObject:[responseData valueForKey:name]]; will add array object. 将添加数组对象。 You try to load this array of data into your table view. 您尝试将此数组数据加载到表视图中。 So you can try this in your tableViewDataSource 所以你可以在tableViewDataSource尝试这个

- (NSInteger)numberOfSectionsInTableView:(UITableView *)aTableView
{
return [[ListOfName objectAtIndex:0] count];
}

It's a Nested Array (means Array inside Array). 它是一个嵌套数组 (表示Array中的数组)。

Howmany Nested Arrays you have ? Howmany嵌套阵列你有吗?

If it's 1 then you can use : 如果它是1那么你可以使用:

NSArray *finalArray = [[NSArray alloc] initWithArray:[yourArray objectAtIndex:0]];

then you can use finalArray to populate the UITableView . 然后你可以使用finalArray来填充UITableView

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM