Ios 带有异步请求的UIrefreshcontrol
我有一个Ios 带有异步请求的UIrefreshcontrol,ios,iphone,objective-c,Ios,Iphone,Objective C,我有一个tableView,在这里我需要实现一个UIRefreshController。这个很好用。我想要的是,当我启动并刷新时,它需要再次执行请求。目前,当我删除fixtures对象时会出现一个问题,但如果我不这样做,它只会添加已经存在的相同fixtures 我做错了什么 [self firstRequest]; //is the request 守则: -(void)viewDidAppear:(BOOL)animated { UIRefreshControl *refreshC
tableView
,在这里我需要实现一个UIRefreshController
。这个很好用。我想要的是,当我启动并刷新时,它需要再次执行请求。目前,当我删除fixtures对象时会出现一个问题,但如果我不这样做,它只会添加已经存在的相同fixtures
我做错了什么
[self firstRequest]; //is the request
守则:
-(void)viewDidAppear:(BOOL)animated {
UIRefreshControl *refreshControl = [[UIRefreshControl alloc] init];
[refreshControl addTarget:self action:@selector(refresh:) forControlEvents:UIControlEventValueChanged];
[self.theTableView addSubview:refreshControl];
}
- (void)refresh:(UIRefreshControl *)refreshControl
{
[fixtures removeAllObjects];
[self firstRequest];
[refreshControl endRefreshing];
}
问题是每次我重新加载时,它都会添加重复项,而当我使用
[fixtures removeAllObjects];
它给了我以下错误:
Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayI objectAtIndex:]: index 3 beyond bounds for empty array'
您没有描述问题的实质……当您完成请求时(当您从web获得数据时),是否重新加载表视图数据?