Today I had the task of added a collection (NSSet) of RouteLocationEventEntity’s to another entity (RouteLocationEntity). I thought this was gonne be easy, I had an example to follow, RouteLocationEntity already had a collection of NoteEntity’s. Easy!
Step 1. I found this code and duplicated it, easy!
Step 2. Go to the datamodel and add this shit, easy!
Step 3. Debug. Stop at a breakpoint after calling addRouteLocationEventsObject and po my RouteLocationEntity. Oh shit…
Why the hell is that collection nil? The Notes property isn’t nil, it is an empty something or-other.
After fumbling around for a while I noticed something.
I suppose the M means many and the O means one. I’m feeling pretty smart at this time, because I don’t know how to change it. So I do what we do so often, dig into the contents of the xcdatamodel file and manually edit it.
becomes this
Now my datamodel looks a little better!
So now, I know there must be a way to do that in Xcode, but it was not apparent to me this morning. I feel stupid for having to ask, but how do you do that in Xcode?