FetchedResultsControllerCollectionViewUpdater
Description
A simple way to deal with the abcense of beginUpdates()
and endUpdates()
methods in UICollectionView.
Provides an implementation of NSFetchedResultsControllerDelegate for updating UICollectionView contents.
Usage example
@IBOutlet weak var collectionView: UICollectionView!
lazy var collectionUpdaterDelegate: CollectionViewUpdaterDelegate = {
let delegate = CollectionViewUpdaterDelegate(collectionView: collectionView)
// Optionally add section name modifier
delegate.sectionIndexTitleForSectionName = { sectionName in
sectionName.uppercased()
}
return delegate
}()
lazy var fetchedResultsController: NSFetchedResultsController<NSManagedObject> = {
let frc: NSFetchedResultsController<NSManagedObject>
// FRC init and setup
frc.delegate = collectionUpdaterDelegate
return frc
}()
override func viewDidLoad() {
do {
try fetchedResultsController.performFetch()
} catch {
handleError(error)
}
}
Installation
FetchedResultsControllerCollectionViewUpdater is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'FetchedResultsControllerCollectionViewUpdater'
Author
Artem Garmash, agarmash.com
License
FetchedResultsControllerCollectionViewUpdater is available under the MIT license. See the LICENSE file for more info.