Mike, The -reloadData is being issued on the main thread:
<NSThread: 0x15622080>{number = 1, name = main} -Carl > On Feb 12, 2016, at 4:19 PM, Michael Swan <michaels...@mac.com> wrote: > > Right before you call reload data log the current thread [NSThread > currentThread]; > If it says anything other than main that's the issue. It happens all the time > since it's easy to forget that whatever callback tells you about the added > data ends up coming in on the background. > > Hope that helps, > Mike Swan > OS X & iOS Developer > TheMikeSwan.com > >> On Feb 12, 2016, at 5:53 PM, cocoa-dev-requ...@lists.apple.com wrote: >> >> Message: 1 >> Date: Fri, 12 Feb 2016 12:37:53 -0800 >> From: Carl Hoefs <newsli...@autonomy.caltech.edu> >> To: "Cocoa-dev@lists.apple.com dev" <cocoa-dev@lists.apple.com> >> Subject: UITableView -reloadData woes >> Message-ID: >> <8cd75bc0-ee70-429d-ab76-61aad7b83...@autonomy.caltech.edu> >> Content-Type: text/plain; charset=utf-8 >> >> iOS 9.2 >> >> Is there a trick to using UITableView -reloadData? I can't get it to do >> anything. >> >> My view controller has a UITableView instance (VC is both UITableView >> delegate and dataSource), and I populate it with cells from my data source >> via the delegate callback method -tableView:cellForRowAtIndexPath:. That >> works fine. >> >> Now, when the data source has additional data, it calls -reloadData to >> rebuild/redisplay the table view, but this has no effect. The delegate >> callback method -tableView:cellForRowAtIndexPath: doesn't get invoked, and >> the contents of the table view don't change. In the debugger, I've verified >> that the UITableView property is valid: >> >> _sbsTableView is: <UITableView: 0x14b29000; frame = (20 74; 528 188); >> clipsToBounds = YES; autoresize = RM+BM; gestureRecognizers = <NSArray: >> 0x146f22a0>; layer = <CALayer: 0x14645640>; contentOffset: {0, 0}; >> contentSize: {528, 616}> >> >> The reload doesn't reload the table, causing an index out of range exception >> downstream when trying to access a row that -reload should have added. >> >> // Reload the table's data >> [_sbsTableView reloadData]; // no visible change onscreen >> // Reposition the table view to display the new entry >> NSIndexPath *indxPath = [NSIndexPath indexPathForRow:user_no >> inSection:sec_no]; >> [_sbsTableView selectRowAtIndexPath:indxPath // <- exception >> animated:YES >> scrollPosition:UITableViewScrollPositionMiddle]; >> [_sbsTableView scrollToRowAtIndexPath:indxPath >> atScrollPosition:UITableViewScrollPositionMiddle >> animated:YES]; >> >> >> The docs say: >> >> 1. "The table view’s delegate or data source calls this method when it wants >> the table view to completely reload its data." >> >> 2. "Call this method to reload all the data that is used to construct the >> table, including cells, section headers and footers, index arrays, and so >> on." >> >> Wouldn't that necessitate the invocation of the delegate callback method >> -tableView:cellForRowAtIndexPath:? FWIW, the next time the app is run, the >> additional data does appear in the table. >> >> There must be something obvious I'm overlooking... >> -Carl >> _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com