I'm using the UIRefreshControl for the first time and I get an exception during the loading of my refresh control.
Here is my declaration :
self.refreshControl = [[UIRefreshControl alloc] init];
self.refreshControl.tintColor = [UIColor grayColor];
[self.refreshControl addTarget:self action:@selector(refreshView:) forControlEvents:UIControlEventValueChanged];
[self.actualitesTableView addSubview:self.refreshControl];
Here are my functions :
- (void)refreshView:(UIRefreshControl *)sender {
[self performSelectorInBackground:@selector(threadAction) withObject:nil];
}
- (void)threadAction {
[self choixMAJ];
NSLog(@"OK1");
[self.refreshControl endRefreshing];
NSLog(@"OK2");
}
When I use the choixMAJ() method, it works perfectly.
Everything's going right and the OK2 is logged but after that, when the refresh control disapeared, the app crashed with this error :
*** -[__NSArrayM removeObject:]: message sent to deallocated instance 0x655a1a0
I don't understand why.. Any ideas ?
Well, you shouldn't call -endRefreshing on a background thread, for starters. UIKit methods (including that one) should be performed on the main thread. I'm not sure that's actually causing your problem, though.
Thanks shusta, it helps me a lot !