Re: Key Paths @count and mutablestrings
Re: Key Paths @count and mutablestrings
- Subject: Re: Key Paths @count and mutablestrings
- From: Benjamin Stiglitz <email@hidden>
- Date: Tue, 4 Nov 2008 12:32:57 -0500
- Mail-followup-to: email@hidden
On Mon, Nov 03, 2008 at 06:55:24PM +0000, Amy Heavey wrote:
> PurchaseOrder is an Entity, with a relationship called products to the
> PurchaseOrderItems Entity which lists the actual items on the order. I'd
> like a column in my Purchase Order tabel to display the number of items
> in the order, so I've tried a number of different things along the lines
> of
> Value: bound to Purchase Order Array Controller
> arrangedObjects
> @count.products
>
> but I get the following error:
> 2008-11-03 18:41:44.928 powizard[8498] [<NSManagedObject 0x654a70>
> valueForUndefinedKey:]: this class is not key value coding-compliant for
> the key @count.
> …
> How do I access the count of a to-many relationship?
You’ve got that backwards; you want “products.@count”.
> I then want to print out some of this data, so I've created a view, and
> got it all laid out, now I just need to populate it with the data. I
> thought the easiest way would be to loop through the info and display
> strings but I'm struggling a bit.
Do you mean print out on a printer, or just display on the screen?
> I figure I need 4 strings, 1 for each 'column' of the table I want, then
> I can just create strings with new lines and it will lay itself out
> correctly.
>
> If I was binding a tablecolumn I would use the following binding:
>
> arrangedObjects.qty[Purchase Order Items Array Controller
> (NSArrayController)]
>
> so how do I loop through the array, setting the string value each time to
> create a string along the lines of @"1234/n3698/n3258/n4587/n" where
> 1234, 3698, 3258 and 4587 are the qty values?
I’m not really clear what you’re doing here. You’ll want to go through
your array controller’s arrangedObjects accessor to get the values, and
then pull out the keys on your own.
-Ben
_______________________________________________
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