Printing all values in CoreStoreObject? #195

Open
opened 2025-12-29 18:24:14 +01:00 by adam · 1 comment
Owner

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.
adam added the enhancement label 2025-12-29 18:24:14 +01:00
Author
Owner

@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.

@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.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/CoreStore-JohnEstropia#195