Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

newtoiphonesdk

macrumors 6502a
Original poster
Jul 30, 2010
567
2
I'm trying to get a blog app to refresh the articles, and add any new articles that may have been written since prior launch.

The TableView uses an array _allEntries of all the articles in the feed. I was told that when the user clicks the refresh button, i should clear the array, and after clearing it, run the original [self refresh] code to parse the rss and repopulate the table view. I am doing that with:

Code:
[_allEntries removeAllObjects];
[self refresh];
However, when I do that, it crashes with error:

Code:
*** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 4 beyond bounds for empty array'
 
What does [self refresh] do?

The error you are getting is because you initially had an array with more than 4 articles. In your table view's delegate you returned the row count which was equal to the number of objects in your array. So the table asked for the 4th object in your array, and as you removed all objects from your array you got a range exception.

You should either reload the table or insert/delete specific rows and return a correct row count to your table whenever you add/remove objects to your array.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.