CocoaPods trunk is moving to be read-only. Read more on the blog, there are 16 months to go.

FetchedResultsControllerCollectionViewUpdater 0.1.0

FetchedResultsControllerCollectionViewUpdater 0.1.0

Maintained by Artem Garmash.



FetchedResultsControllerCollectionViewUpdater

CI Status Version License Platform

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.