开发者

Problem with numberOfRowsInSection and dictionaries

开发者 https://www.devze.com 2023-01-11 14:01 出处:网络
I have created a dictionary with a number of different bits of information all pulled from and xml feed. I now wan开发者_JAVA百科t to pull certain parts from the dictionary into areas to create my tab

I have created a dictionary with a number of different bits of information all pulled from and xml feed. I now wan开发者_JAVA百科t to pull certain parts from the dictionary into areas to create my tableview.

so far creating the section headers was fine, but having a problem with the numberofrowsinsection part:

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
   return [[sections objectAtIndex: section] objectForKey: @"itemsCount"];
}

This gives the following error: warning: return makes integer from pointer without a cast Any help welcome on this very much newbie :)


Try

return [[[sections objectAtIndex: section] objectForKey: @"itemsCount"] intValue];


objectForKey returns id -- which is not automatically convertible to NSInteger. You need to cast this to the object type that you put in the dictionary and then convert that to NSInteger.

0

精彩评论

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