UITableView via NSFetchedResultsControllerDelegate, select first record by default?
Posted
by deafgreatdane
on Stack Overflow
See other posts from Stack Overflow
or by deafgreatdane
Published on 2010-04-17T15:50:51Z
Indexed on
2010/04/17
15:53 UTC
Read the original article
Hit count: 326
cocoa-touch
|core-data
I have a UITableView that gets populated from CoreData via a controller that implements NSFetchedResultsControllerDelegate. How can I have it automatically select the first row (and fire the tableView:didSelectRowAtIndexPath message)?
The tableview is used for a variety of predicate queries, so I'm suspicious of solutions that work on the UIViewController lifecycle (viewDidLoad, etc), but I'm new to the platform, so I'm open.
I've tried a variety of things, but I'm not sure where in the call stack to put it. I've tried calling cell.selected = true
inside tableView:cellForRowAtIndex: method, but that just ends up turning the cell black (and doesn't fire the selected callback method)
A tagent question, with all the delegating and core data protocols, does it imply asynchronous data fetch (multiple threads)? Or is the NSFetchedResultsController calling all its related methods in the same thread? Maybe I'm just scared that if it is async, there would be race conditions that would be tough to troubleshoot later.
© Stack Overflow or respective owner