Drop me an email if you'd like to hire me (part time) or learn more about what I do. You can read about my experience and references on LinkedIn.
Swift 2: @NSManaged can be used for autogenerated methods
Another addition to Swift 2 in Xcode 7 beta 5. We can use @NSManaged to declare
autogenerated methods when using to-many relationships.
I see it very useful. Let’s say you’ve got Library and Book entities. Library
has to-many books relationship. With new Xcode and @NSManaged you can declare
autogenerated methods in the Library entity (manually).
This is how it look like:
This is nice, I appreciate that we’re able to do this. I remember I had to write
such methods from scratch recently.
I noticed an issue here. Yes we can declare such methods, but what was the
problem to make them generated anyway and put them in to the
Entity+CoreDataProperties.swift files? When generating Objective-C subclasses even
in a Swift project the methods are presented there. When generating in Swift
language - NO. Opened rdar://22177139 to keep an eye on this.
This is from entity class generated in Objective-C language.
There is a lot more methods to declare manually when you mark relationship to be ordered.
Do not want to do this manually… Hope they fix it soon :)
Another issue that I am waiting to be fixed by Apple is the one with ordered to-many
relationship and those auto-generated methods. This bug exists for a very long time.
Don’t know if there are bug reports for this one. I think it is from the time when
Core Data and this functionality has been released for the first time. Let’s say
I want to add some Book to a Library:
The only workaround for this is to re-implement those methods.
Opened rdar://22177512 - Hope they fix it finally.