Originally created by @IdoRabin on GitHub (Jun 2, 2020).
Considering the introduction of identifiable is swift
one can imagine an extension for ImportableUniqueObject leveraging situations where ImportSource is Identifiable, using ImportSource.ID in relation to UniqueIDType, uniqueIDKeyPath and uniqueIDValue
I've implemented a crude base class for a DBTable, but am sure one can create a much better thingie as an extension to the ImportableUniqueObject protocol..
Originally created by @IdoRabin on GitHub (Jun 2, 2020).
Considering the introduction of `identifiable` is swift
one can imagine an extension for `ImportableUniqueObject` leveraging situations where `ImportSource is Identifiable`, using `ImportSource.ID` in relation to `UniqueIDType`, `uniqueIDKeyPath` and `uniqueIDValue`
I've implemented a crude base class for a DBTable, but am sure one can create a much better thingie as an extension to the `ImportableUniqueObject` protocol..
```
class DBTable<Entity:Codable & Hashable & Identifiable, DBEntity:NSManagedObject & ImportableUniqueObject> {
...
}
```
adam
added the question label 2025-12-29 15:29:17 +01:00
@JohnEstropia commented on GitHub (Jun 3, 2020):
@IdoRabin I'm sorry, did you have any question or was there something not working for you?
If you were asking how to do this, you'll have to declare:
```swift
extension ImportableUniqueObject where Self: Identifiable {
var id: UniqueIDType: {
return self.uniqueIDValue
}
}
```
somewhere in your codebase.
@JohnEstropia commented on GitHub (Jun 3, 2020):
Also to add, CoreStore intentionally does not implement `Identifiable` by default as it is a use-case dependent semantic.
For example, you are free to use multiple properties as the ID:
```swift
class Person: NSManagedObject: Identifiable {
@NSManaged var firstName: String
@NSManaged var lastName: String
// ...
struct ID: Hashable {
var firstName: String
var lastName: String
}
var id: ID {
return ID(firstName: self.firstName, lastName: self.lastName)
}
}
```
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Originally created by @IdoRabin on GitHub (Jun 2, 2020).
Considering the introduction of
identifiableis swiftone can imagine an extension for
ImportableUniqueObjectleveraging situations whereImportSource is Identifiable, usingImportSource.IDin relation toUniqueIDType,uniqueIDKeyPathanduniqueIDValueI've implemented a crude base class for a DBTable, but am sure one can create a much better thingie as an extension to the
ImportableUniqueObjectprotocol..@JohnEstropia commented on GitHub (Jun 3, 2020):
@IdoRabin I'm sorry, did you have any question or was there something not working for you?
If you were asking how to do this, you'll have to declare:
somewhere in your codebase.
@JohnEstropia commented on GitHub (Jun 3, 2020):
Also to add, CoreStore intentionally does not implement
Identifiableby default as it is a use-case dependent semantic.For example, you are free to use multiple properties as the ID:
@IdoRabin commented on GitHub (Sep 25, 2020):
thanks.