Re: Core Data: right way to gather all elements of a to-many relationship?
Re: Core Data: right way to gather all elements of a to-many relationship?
- Subject: Re: Core Data: right way to gather all elements of a to-many relationship?
- From: "I. Savant" <email@hidden>
- Date: Wed, 11 Feb 2009 15:48:41 -0500
On Wed, Feb 11, 2009 at 3:32 PM, Luke Evans <email@hidden> wrote:
> Indeed it is defined in a subclass of NSManagedObject as:
>
> @property(readonly, retain) NSSet *elements;
>
> It is read only as writing is done via KVC patterned write accessors (i.e.
> addElementsObject, removeElementsObject).
>
> The implementation does nothing more than:
>
> @dynamic elements;
This may demonstrate a lack of understanding on my part, but ... are
you sure of this assertion? It's been awhile since I've read the
pertinent documentation, but something about this assertion bugs me.
:-)
Can you cite your sources if for no other reason than for me to
(re)educate myself?
The documentation (Core Data Programming Guide --> Managed Object
Accessor Methods --> Custom To-Many Relationship Accessor Methods)
spells out all the stipulations for custom to-many accessors and the
code example is:
@property NSSet *employees;
... without the readonly flag. I would not expect this to hand back
an array versus a set, but I would also not specify a to-many
relationship as a read-only property.
> I'm now defending against the wrong type of receiver representing the
> relationship by first sending a -count message and only if this is non-zero
> sending -allObjects.
> This seems to be working, though it's an unsatisfactory band-aid applied
> without true knowledge of how the circumstance is arising.
Yeah, I'd feel pretty dirty relying on that. :-)
--
I.S.
_______________________________________________
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