I embedded in my project EGOTableViewPullRefresh , everything works and updates fine, but when I pull the view down too much to update, app crashes with the error:
2012-04-24 19:02:56.670 Test [3927: f803] * Terminating app due to uncaught exception 'NSRangeException', reason: '* - [__NSArrayM objectAtIndex:]: index 2 beyond bounds for empty array' * First throw call stack:
the piece of code
self.tabBarController = [[[UITabBarController alloc] init] autorelease];
NSMutableArray * viewControllers = [[NSMutableArray alloc] init];
//plist file full path
NSString *urlStr = [[NSString alloc]
initWithFormat:@"http://www.test.com/data.xml?seedVar=%f",
(float)random()/RAND_MAX];
NSURL *url = [NSURL URLWithString:urlStr];
NSDictionary *dict = [[NSDictionary alloc] initWithContentsOfURL:url];
//Get the folder array
NSArray * subscriptionFolders = [dict objectForKey:@"Folders"];
UPDATE
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
[cell.textLabel setNumberOfLines:2];
[cell.detailTextLabel setNumberOfLines:3];
[cell setAccessoryType:UITableViewCellAccessoryDisclosureIndicator];
}
RSSItem * rssItem = (RSSItem *)[_rssParser.rssItems objectAtIndex:indexPath.row];
[cell.textLabel setText:rssItem.title];
[cell.detailTextLabel setText:rssItem.summary];
return cell;
}
can you help me with this?
I found a solution. When I called rssParser in reloadTableViewDataSource it crash. When I tryed to call rssParser in dataSourceDidFinishLoadingNewData all works fine without crash.
- (void)reloadTableViewDataSource{
[super performSelector:@selector(dataSourceDidFinishLoadingNewData) withObject:nil afterDelay:2.0];
}
- (void)dataSourceDidFinishLoadingNewData{
[_rssParser start];
[refreshHeaderView setCurrentDate];
[super dataSourceDidFinishLoadingNewData];
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.