I have a UITableView
that uses a YapDatabaseView
and a YapDatabaseViewMappings
. I am trying to programmatically have my table view scroll to the position of a given object in the database...
With CoreData I was doing:
NSIndexPath *indexPath = [self.fetchedResultsController indexPathForObject:myObject];
[self.tableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionMiddle animated:YES];
Any equivalent to that scenario with YapDatabase
?
Yes it does. You can use the API
indexPathForKey(:inCollection:withMappings)
which is available onYapDatabaseViewTransaction
.e.g.
This assumes that you can access the key and collection from your object.
If you're using Swift, then check out TaylorSource which makes this a doddle.