Advertisement
priore

fix for crash when called the reloadData of a UITableView

Apr 29th, 2014
1,203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // workaround for crash when called the reloadData method during scrolling of a UITableView
  2. [yourTableView performSelectorOnMainThread:@selector(reloadData) withObject:nil waitUntilDone:NO];
  3.  
  4. // workaround for crash when called the reloadData method during scrolling of a UICollectionView
  5. [[NSOperationQueue mainQueue] addOperationWithBlock:^{
  6.     [yourCollectionView performSelectorOnMainThread:@selector(reloadData) withObject:nil waitUntilDone:NO];
  7. }];
  8.  
  9. // NOTE: remember that you should always cancel the request in dealloc!!
  10. - (void)dealloc
  11. {
  12.     [NSObject cancelPreviousPerformRequestsWithTarget:yourTableView];
  13.     [NSObject cancelPreviousPerformRequestsWithTarget:yourCollectionView];
  14.     [super dealloc];
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement