Skip to content

cms7912/SingleFetchedResultController

 
 

Repository files navigation

SingleFetchedResultController

Like NSFetchedResultsController but for a single managed object. Please see the associated blogpost.

Usage

class MyClass {
    var frc: SingleFetchedResultController<Profile>?
    ...
    
    func setup() throws {
        let predicate = NSPredicate(format: "username = %@", username)
        frc = SingleFetchedResultController(predicate: predicate,
                                            managedObjectContext: moc,
                                            onChange: { (profile, changeType) in
            // will be called after the first fetch and after each change to the object
            print(profile.username)
        })
    
        try frc?.performFetch()
    }
}

Requirements

iOS 8 and above.

Author

Arkadiusz Holko:

About

Like NSFetchedResultsController but for a single managed object.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Swift 68.6%
  • Ruby 16.5%
  • Objective-C 14.9%