要运行示例项目,请克隆仓库,并首先在 Example 目录中运行 pod install
。
就像使用 NSFetchedResultsController 一样使用它,设置它:
- (void)viewDidLoad {
[super viewDidLoad];
self.dataSource = [NSMutableOrderedSet orderedSetWithObject:[[Person alloc] initWithName:@"sherry"]];
SMBFetchedResults *fetchedResults = [[SMBFetchedResults alloc] initWithMutableData:self.dataSource];
self.fetchedResultsController = [[SMBFetchedResultsController alloc] initWithFetchedResults:fetchedResults title:@"SMB" delegate:self];
}
将插入操作添加到 SMBFetchedResults 数据结构中
- (IBAction)insertButtonClick:(id)sender {
Person *person = [[Person alloc] initWithName:@"david"];
[self.fetchedResultsController.fetchedResults insertObject:person inDataAtIndex:0];
}
这就完成了!
SMBFetchedResultsController 通过 CocoaPods 提供。要安装它,只需将以下行添加到您的 Podfile 中:
pod "SMBFetchedResultsController"
David Fu,[email protected]
SMBFetchedResultsController 可在 MIT 许可证下使用。有关更多信息,请参阅 LICENSE 文件。