Originally created by @cdelaet on GitHub (Jan 12, 2018).
Would it be possible to make CoreStoreObject to implement CustomStringConvertible by default?
It would be nice if print(myCoreStoreObject) printed all keys and their values out of the box. I use that feature a lot to verify / debug my code.
Originally created by @cdelaet on GitHub (Jan 12, 2018).
Would it be possible to make `CoreStoreObject` to implement `CustomStringConvertible` by default?
It would be nice if `print(myCoreStoreObject)` printed all keys and their values out of the box. I use that feature a lot to verify / debug my code.
That’s not what CustomStringConvertible is for. You want CustomReflectable or CustomDebugStringConvertible (I’m not sure why that last one exists).
On a related note, Core Data documentation explicitly discourages overriding description to fire a fault. I implement TextOutputStreamable instead. In fact, I never add conformance to CustomStringConvertible directly, only through LosslessStringConvertible. TextOutputStreamable is more efficient, and takes priority for almost everything. It also doesn’t leave uselessly identical properties everywhere.
@Saklad5 commented on GitHub (May 6, 2020):
That’s not what `CustomStringConvertible` is for. You want `CustomReflectable` or `CustomDebugStringConvertible` (I’m not sure why that last one exists).
On a related note, Core Data documentation explicitly discourages overriding `description` to fire a fault. I implement `TextOutputStreamable` instead. In fact, I never add conformance to `CustomStringConvertible` directly, only through `LosslessStringConvertible`. `TextOutputStreamable` is more efficient, and takes priority for almost everything. It also doesn’t leave uselessly identical properties everywhere.
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 @cdelaet on GitHub (Jan 12, 2018).
Would it be possible to make
CoreStoreObjectto implementCustomStringConvertibleby default?It would be nice if
print(myCoreStoreObject)printed all keys and their values out of the box. I use that feature a lot to verify / debug my code.@Saklad5 commented on GitHub (May 6, 2020):
That’s not what
CustomStringConvertibleis for. You wantCustomReflectableorCustomDebugStringConvertible(I’m not sure why that last one exists).On a related note, Core Data documentation explicitly discourages overriding
descriptionto fire a fault. I implementTextOutputStreamableinstead. In fact, I never add conformance toCustomStringConvertibledirectly, only throughLosslessStringConvertible.TextOutputStreamableis more efficient, and takes priority for almost everything. It also doesn’t leave uselessly identical properties everywhere.