-
-
Notifications
You must be signed in to change notification settings - Fork 255
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is it possible to have multiple ImportableUniqueObjects for the same NSManageObject? #469
Labels
Comments
Sure, I do something like this a lot in my projects: class Hotel: CoreStoreObject, ImportableUniqueObject {
// ...
enum ImportSource {
case hotelJSON([String: Any])
case hotelPriceJSON([String: Any])
}
} then in your import code: try transaction.importUniqueObjects(
Into<Hotel>(),
sourceArray: jsonArray.map({ .hotelJSON($0) }) // or .hotelPriceJSON depending on the method
) Then in your public func update(
from source: ImportSource,
in transaction: BaseDataTransaction
) throws {
switch source {
case .hotelJSON(let json):
// parse as how you expect
case .hotelPriceJSON(let json):
// parse as how you expect
}
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have two web fetches that update the same object at different times.
Hotel <- HotelJSON
Hotel <- HotelPriceJSON
Both JSONs use HotelId as the unique key. Is it possible to make those both unique objects? Prrotocol can only be declared on Hotel once. Is there a workaround?
The text was updated successfully, but these errors were encountered: