https://github.com/fastred/singlefetchedresultcontroller
Like NSFetchedResultsController but for a single managed object.
https://github.com/fastred/singlefetchedresultcontroller
Last synced: over 1 year ago
JSON representation
Like NSFetchedResultsController but for a single managed object.
- Host: GitHub
- URL: https://github.com/fastred/singlefetchedresultcontroller
- Owner: fastred
- License: mit
- Created: 2016-06-06T16:49:01.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2017-08-23T00:30:48.000Z (almost 9 years ago)
- Last Synced: 2025-04-19T23:45:22.853Z (over 1 year ago)
- Language: Swift
- Homepage: http://holko.pl/2016/06/07/single-object-core-data/
- Size: 12.7 KB
- Stars: 26
- Watchers: 2
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# SingleFetchedResultController
Like NSFetchedResultsController but for a single managed object. Please see the [associated blogpost][blogpost].
## Usage
```swift
class MyClass {
var frc: SingleFetchedResultController?
...
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:
* [@arekholko on Twitter](https://twitter.com/arekholko)
* [Holko.pl](http://holko.pl/)
[blogpost]: http://holko.pl/2016/06/07/single-object-core-data/