-
-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Better API for creating entity descriptions and inserting managed objects #87
Comments
Generate entity name via |
Could implement this in |
Draft design: protocol CoreDataEntityProtocol {
static var entityName: String { get }
static var defaultSortDescriptors: [SortDescriptor] { get }
}
extension CoreDataEntityProtocol where Self: NSManagedObject {
static func defaultEntityName() -> String {
return "\(Self.self)"
}
static var fetchRequest: NSFetchRequest<Self> {
let request = NSFetchRequest<NSManagedObject>(entityName: entityName)
request.sortDescriptors = defaultSortDescriptors
return request as! NSFetchRequest<Self>
}
static func entity(context: NSManagedObjectContext) -> NSEntityDescription {
return NSEntityDescription.entity(forEntityName: entityName, in: context)!
}
} |
3 tasks
jessesquires
added a commit
that referenced
this issue
Jul 25, 2016
jessesquires
added a commit
that referenced
this issue
Sep 15, 2016
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
Would like to improve the existing
entity()
func, and provide a better/easier way to create an entity description and insert managed objects.Daniel has great approaches outlined in this talk:
https://realm.io/news/tryswift-daniel-eggert-modern-core-data/
I think we should do this, or something similar.
The text was updated successfully, but these errors were encountered: