开发者

implementing UITableView sections from an NSDictionary objects

I want to use an NSDictionary to populate a table view. Are there any tutorials to 开发者_C百科show me how this is done.


Need to check what contains inside NSDictionary, Here, I assume that there would be NSString as values inside Main NSDictionary, here is code for that

- (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;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜