Re: Ordered to-many relationship CoreDataGeneratedAccessors
Re: Ordered to-many relationship CoreDataGeneratedAccessors
- Subject: Re: Ordered to-many relationship CoreDataGeneratedAccessors
- From: Gordon Apple <email@hidden>
- Date: Mon, 31 Mar 2014 17:05:30 -0600
- Thread-topic: Ordered to-many relationship CoreDataGeneratedAccessors
One thing you are missing, is that, as far as I know, the generated
accessors are still broken. You have to write your own. I did find a set
of macros someone wrote for this, but haven¹t tried them yet because I had
already written many of my own sets of accessors.
Two more things to watch out for (been bitten by both):
1. Note that [(NSOrderedSet) array] does not return a new array. If you
change the orderedSet, it will change the returned array. It is a
³representation² of the orderedSet as an array, not a new array.
2. moveObjectsFromIndexes:toIndex does not work in the way you might
expect, like moving table elements to the dropped index location. No way,
no how. You have to first figure out what the new insert index will be after
removing the objects, because that is what this routine expects as its index
input. I¹ve filed bug reports on this, but they haven¹t updated it. The
(prigrammer) user should not have to know how this routine works internally
in order to use it properly. It should work the way it is displayed in a
table, so the index should be the row number where you dropped it in the
table.
Message: 1 Date: Mon, 31 Mar 2014 09:32:50 -0500 From: Fritz Anderson
<email@hidden> To: Rick Mann <email@hidden> Cc: Cocoa
dev <email@hidden> Subject: Re: Ordered to-many relationship
CoreDataGeneratedAccessors Message-ID:
<email@hidden> Content-Type:
text/plain; charset=windows-1252 On 29 Mar 2014, at 3:11 AM, Rick Mann
<email@hidden> wrote: > I'm getting > > -[WireSegment
replaceObjectInNodesAtIndex:withObject:]: unrecognized selector sent to
instance > > When I try to send that message. This is one of the
"CoreDataGeneratedAccessors", for an ordered to-many relationship. I don't
see anything in the docs about those. What am I missing? > > -- > Rick I
assume "WireSegment" is an object variable despite the name. I believe that
what KVC is giving you for .nodes is an NSSet. What you want to do is
[[wireSegment mutableOrderedSetValueForKey: @"nodes"] replaceObjectAtIndex:
anIndex withObject: newObject]; which you¹d likely want to wrap in a
method of your own. I think. Written in Mail, uncompiled, untested. F
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden