Core Data brings a lot of power to an app and continues to evolve, but it can have rough spots when you’re working in Swift. What if you want to save an enum pr a struct? Does it help if your data is Codable? What’s the best way to create Swift-friendly model classes? This session will cover techniques and gotchas for integrating Core Data with your Swift code
It’s a bit of a mystery to me why Xcode’s generated code for Core Data continues to be so unhelpful compared with mogenerator.
Another option for his enum
example is that, if you have the ability to change the enum
’s definition, you can make it @objc enum
. Then you can just declare the @NSManaged
property using the proper type instead of having to write a getter and setter. The disadvantage of this, though, is that an @objc enum
only shows up as the type name if you ask for its description
. To see the actual case, e.g. when logging, you would need to implement CustomStringConvertible
.
There are also a lot more videos from the try! Swift Conference.
Previously: Using Core Data With Swift, Generating Core Data Swift, Modern Core Data With Swift, momdec: Core Data Model Decompiler.