Fun with Type Introspection, Mirroring and Reflection
summary
Uses Swift's Mirror struct and protocol extensions to implement a runtime serializer and a Core Data saver for plain structs. Code builds a toJSON implementation (one level deep, notes recursion needed) and a save that maps reflected property names to an NSManagedObject and writes to Core Data. Demo runs in a Playground, prints JSON and then fetches a saved NSManagedObject, proving the save works end-to-end.
AI-written summary · about
