开发者

Load more cells problem

开发者 https://www.devze.com 2023-04-03 06:06 出处:网络
i use MWFeedParser library to parse xml. when i change the numberOfRowsInSection to +1 开发者_运维问答(return [itemsToDisplay count] +1;)

i use MWFeedParser library to parse xml. when i change the numberOfRowsInSection to +1 开发者_运维问答(return [itemsToDisplay count] +1;) to make the last cell row for the Load more option my app crash in this line: MWFeedItem *item = [itemsToDisplay objectAtIndex:indexPath.row];

any idea why this happens?


wel you are trying the get an item from an array that is beyond the the number of items in that array. (also accept some anser, people are more willing to anser if you accept answers)

Ex: You do a plus 1 in the numberOfRowsInSection which, by example, return 11. That means that there are 10 item in the itemsToDisplay array. You are retrieving item from the itemsToDisplay in with MWFeedItem *item = [itemsToDisplay objectAtIndex:indexPath.row] but you cant retrieve item number 11 because it does not exists.

In the - (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath:

if (indexPath.row < [itemsToDisplay count]) {
   MWFeedItem *item = [itemsToDisplay objectAtIndex:indexPath.row];
   // Set the cell here
} else {
   //create a cell with the text "Load More"
}
0

精彩评论

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

关注公众号