YapDatabase 是否具有与 NSFetchedResultsController indexPathForObject: 等效的功能?
Does YapDatabase have an equivalent to NSFetchedResultsController indexPathForObject:?
我有一个使用 YapDatabaseView
和 YapDatabaseViewMappings
的 UITableView
。我正在尝试以编程方式让我的 table 视图滚动到数据库中给定对象的位置...
我正在使用 CoreData:
NSIndexPath *indexPath = [self.fetchedResultsController indexPathForObject:myObject];
[self.tableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionMiddle animated:YES];
是否有与 YapDatabase
相同的场景?
是的。您可以使用 API indexPathForKey(:inCollection:withMappings)
YapDatabaseViewTransaction
.
例如
YapDatabaseViewTransaction *viewTransaction = [transaction ext:"view name"];
NSIndexPath *indexPath = [viewTransaction indexPathForKey(myObject.key, inCollection: myObject.collection, withMappings: mappings];
这假定您可以从您的对象访问密钥和集合。
如果您使用的是 Swift,请查看 TaylorSource which makes this a doddle。
我有一个使用 YapDatabaseView
和 YapDatabaseViewMappings
的 UITableView
。我正在尝试以编程方式让我的 table 视图滚动到数据库中给定对象的位置...
我正在使用 CoreData:
NSIndexPath *indexPath = [self.fetchedResultsController indexPathForObject:myObject];
[self.tableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionMiddle animated:YES];
是否有与 YapDatabase
相同的场景?
是的。您可以使用 API indexPathForKey(:inCollection:withMappings)
YapDatabaseViewTransaction
.
例如
YapDatabaseViewTransaction *viewTransaction = [transaction ext:"view name"];
NSIndexPath *indexPath = [viewTransaction indexPathForKey(myObject.key, inCollection: myObject.collection, withMappings: mappings];
这假定您可以从您的对象访问密钥和集合。
如果您使用的是 Swift,请查看 TaylorSource which makes this a doddle。