Iphone 从NSDictionary对象实现UITableView节
我想使用NSDictionary来填充表视图。是否有任何教程向我展示如何做到这一点。需要检查NSDictionary中包含的内容,在这里,我假设在主NSDictionary中会有NSString作为值,下面是代码Iphone 从NSDictionary对象实现UITableView节,iphone,Iphone,我想使用NSDictionary来填充表视图。是否有任何教程向我展示如何做到这一点。需要检查NSDictionary中包含的内容,在这里,我假设在主NSDictionary中会有NSString作为值,下面是代码 - (NSInteger)numberOfSectionsInTableView:(UITableView *)tV{ return 1; } - (NSInteger)tableView:(UITableView *)table numberOfRowsInSection:(NSIn
- (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
时都依赖于它是相同的。是的,但是开发人员可以在另一个数组中获取所有键,并根据自己的要求对其进行排序,然后可以使用该数组。我需要一个当前示例及其源代码,谢谢