Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/41.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 从NSDictionary对象实现UITableView节_Iphone - Fatal编程技术网

Iphone 从NSDictionary对象实现UITableView节

Iphone 从NSDictionary对象实现UITableView节,iphone,Iphone,我想使用NSDictionary来填充表视图。是否有任何教程向我展示如何做到这一点。需要检查NSDictionary中包含的内容,在这里,我假设在主NSDictionary中会有NSString作为值,下面是代码 - (NSInteger)numberOfSectionsInTableView:(UITableView *)tV{ return 1; } - (NSInteger)tableView:(UITableView *)table numberOfRowsInSection:(NSIn

我想使用NSDictionary来填充表视图。是否有任何教程向我展示如何做到这一点。

需要检查NSDictionary中包含的内容,在这里,我假设在主NSDictionary中会有NSString作为值,下面是代码

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tV{
return 1;
}
- (NSInteger)tableView:(UITableView *)table numberOfRowsInSection:(NSInteger)section{
return [dictMain count];
}

- (UITableViewCell *)tableView:(UITableView *)tV cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *reuseIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:reuseIdentifier];
if (cell==nil) {
    cell = [[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuseIdentifier] autorelease];
}
NSString *value = [dicMain objectForKey:[[dicMain allKeys] objectAtIndex:indexPath.row]];
cell.textLabel.text = value;
return cell;
}

allKeys
不会为您提供具有可预测顺序的数组。因此,我们不应该每次调用
allKeys
时都依赖于它是相同的。是的,但是开发人员可以在另一个数组中获取所有键,并根据自己的要求对其进行排序,然后可以使用该数组。我需要一个当前示例及其源代码,谢谢