mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-01-11 20:00:30 +01:00
Generic fetch #86
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @lucasiscovici on GitHub (Sep 24, 2016).
Hey someone have an idea please ?
func fetch<T: NSManagedObject>(_ myconfig:String) -> [T] { return CoreStore.fetchAll(From<T>(myconfig)) }@JohnEstropia commented on GitHub (Sep 27, 2016):
Hi, thank you for the feedback!
I'm not sure I understand your question. Are you proposing to add your method to CoreStore?
If so, CoreStore intentionally avoids shared methods like this because fetches can come from either the DataStack (readonly)
or any transaction (readwrite).
so sorry, any utility that abstracts away the datastack and the transaction is highly unlikely to be added to CoreStore.
If I misunderstood your question, please clarify.
@lucasiscovici commented on GitHub (Sep 27, 2016):
Thanks for you answer!
i want to create an abstract class CoreStoreHelper
`
}
`
To help my NSManagedObject classes Helper
ex:
`
import Foundation
}
`
I succeed my generic fetch
i create From object
`
@JohnEstropia commented on GitHub (Sep 28, 2016):
You should be able to create a generic
From:BUT, the compiler cannot guarantee that your
self.stringhas any relation with<T: NSManagedObject>. You want to design a generic function but your input (var string) are dynamic.If you want to make
CoreStoreHelperfully generic, you will have to make it generic@JohnEstropia commented on GitHub (Sep 29, 2016):
I'll close this issue for now. If you have other questions feel free to continue the discussion :)