I have a UITableViewController subclass that calls [self.tableView reloadData]
from the main queue whenever it needs to clear accessory views from all of its cells. The problem is, I get this crash log indicating that numberOfRowsInSection: was sent to the wrong object when I reload the tableView. The message I get is: -[UIProxyObject tableView:numberOfRowsInSection:]: unrecognized selector sent to instance
and here is the crash log:
Fatal Exception: NSInvalidArgumentException
0 CoreFoundation 0x23682a98c __exceptionPreprocess
1 libobjc.A.dylib 0x235a039f8 objc_exception_throw
2 CoreFoundation 0x2367471c8 -[NSOrderedSet initWithSet:copyItems:]
3 CoreFoundation 0x2368301d4 ___forwarding___
4 CoreFoundation 0x236831e6c _CF_forwarding_prep_0
5 UIKitCore 0x2633600ec -[UITableView _numberOfRowsInSection:]
6 UIKitCore 0x2633702d4 -[UISectionRowData refreshWithSection:tableView:tableViewRowData:]
7 UIKitCore 0x2633742e8 -[UITableViewRowData numberOfRows]
8 UIKitCore 0x263331ee8 -[UITableView noteNumberOfRowsChanged]
9 UIKitCore 0x2633315dc -[UITableView reloadData]
10 Lob 0x1028afcfc __49-[LBSiteListTableViewController clearLoadingCells]_block_invoke + 160 (LBSiteListTableViewController.m:160)
11 libdispatch.dylib 0x236268a38 _dispatch_call_block_and_release
12 libdispatch.dylib 0x2362697d4 _dispatch_client_callout
13 libdispatch.dylib 0x236217008 _dispatch_main_queue_callback_4CF$VARIANT$mp
14 CoreFoundation 0x2367bc32c __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__
15 CoreFoundation 0x2367b7264 __CFRunLoopRun
16 CoreFoundation 0x2367b67c0 CFRunLoopRunSpecific
17 GraphicsServices 0x2389b779c GSEventRunModal
18 UIKitCore 0x263135c38 UIApplicationMain
19 Lob 0x102856f30 main + 14 (main.m:14)
20 libdyld.dylib 0x23627a8e0 start
This is the code I run in my table view controller:
- (void) clearLoadingCells {
dispatch_async(dispatch_get_main_queue(), ^{
[[LBAppDelegate tabBarController] clearLoading];
[self.tableView reloadData];
});
}
and in my delegate, I maintain a list of URLs that are loading (just strings and a boolean):
- (void) clearLoading {
[busyList removeAllObjects];
}
Unfortunately, I cannot reproduce this crash for myself, I am only seeing the logs in my Firebase console for Crashlytics.
instead of using [self.tableView reloadData] why dont you use [self reloadData()]; as your class is UITableViewController subclass.
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.