Objective-C Tips & Trick - Prioregroup.com
[Objective-C] fix for crash when called the reloadData of a UITableView
       
back

// workaround for crash when called the reloadData method during scrolling of a UITableView
[yourTableView performSelectorOnMainThread:@selector(reloadData) withObject:nil waitUntilDone:NO];

// workaround for crash when called the reloadData method during scrolling of a UICollectionView
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
    [yourCollectionView performSelectorOnMainThread:@selector(reloadData) withObject:nil waitUntilDone:NO];
}];

// NOTE: remember that you should always cancel the request in dealloc!!
- (void)dealloc
{
    [NSObject cancelPreviousPerformRequestsWithTarget:yourTableView];
    [NSObject cancelPreviousPerformRequestsWithTarget:yourCollectionView];
    [super dealloc];
}






Copyright © 1996-2018 Centro Studi Informatica di Danilo Priore. All rights reserved. P.I.10149810581.
prioregroup.com