Reputation: 2684
How to implement custom property validation methods for NSManagedObject
subclasses in Xcode 8.0 or above? How we can create an NSManagedObject
subclasses in Xcode 8.0?
Before Xcode 8.0
Xcode -> File -> New -> File -> Core Data -> NSManagedObject Subclass
Upvotes: 0
Views: 65
Reputation: 70966
For Xcode 8 or higher, NSManagedObject
subclasses are created automatically unless you tell Xcode to not do that. With Swift you can let Xcode create a subclass, or create your own subclass and let Xcode add an extension with attribute declarations, or tell Xcode to not automatically generate anything. It's not about Swift 3.0 or 4.0, it's about Xcode.
You choose one of these in the model editor. "Class Definition" is the default.
Validation methods work the same as they ever did. You implement them in a managed object subclass. You can also implement them in an extension on that class.
Upvotes: 1