0
votes

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

1
You ask for Swift 3 and 4 ? - Arrabidas92
@Arrabidas92 Swift 3.0 - Mannopson
Here is how through Apple documentation (Look for Creating NSManagedObject Subclasses) : developer.apple.com/library/content/documentation/Cocoa/… - Arrabidas92
@Arrabidas92 No mate! I think it's not for Swift 3.0 or later. But thanks for your attention. I appreciate it. - Mannopson
Well I see at the bottom of the documentation : Updated 2017-03-27 - Arrabidas92

1 Answers

1
votes

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.

Xcode managed object class generation

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.