Re: Key Paths @count and mutablestrings
On 4 Nov 2008, at 17:32, Benjamin Stiglitz 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 [EMAIL PROTECTED] I tried this at the time and it worked, but now I've made other unrelated changes to the app and now it won't? I've cleared out all my other code and associated problems, and I'm at the same point, key path orderReference works, but [EMAIL PROTECTED] doesn't? [Session started at 2008-11-05 20:42:25 +.] 2008-11-05 20:42:28.462 powizard[22921] [_NSFaultingMutableSet 0x165e910 addObserver:forKeyPath:options:context:] is not supported. Key path: @count Thanks, Amy ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Key Paths @count and mutablestrings
I've cleared out all my other code and associated problems, and I'm at the same point, key path orderReference works, but [EMAIL PROTECTED] doesn't? [Session started at 2008-11-05 20:42:25 +.] 2008-11-05 20:42:28.462 powizard[22921] [_NSFaultingMutableSet 0x165e910 addObserver:forKeyPath:options:context:] is not supported. Key path: @count It sounds like you’re trying to bind to the count of an array controller which is already fetching properties through the model key info. Take a look at this message from the archives: http://www.cocoabuilder.com/archive/message/cocoa/2006/12/1/175296 -Ben___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Key Paths @count and mutablestrings
On Mon, Nov 03, 2008 at 06:55:24PM +, 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 [EMAIL PROTECTED] 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 (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Key Paths @count and mutablestrings
On 4 Nov 2008, at 17:32, Benjamin Stiglitz wrote: On Mon, Nov 03, 2008 at 06:55:24PM +, Amy Heavey wrote: … How do I access the count of a to-many relationship? You’ve got that backwards; you want [EMAIL PROTECTED] Fantastic! Thank You, Do you mean print out on a printer, or just display on the screen? I'll be displaying it in a view so it can be saved to PDF. 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. Is there an easy way to access the existing Array Controller from the code? I have a suitable Array Controller called Purchase Order Items Array Controller in IB, but I don't see a way to reference this in the code. The Array Controller is bound to the selection of another Array Controller. At the moment I'm doing all the work again using a fetch request (not that I've got it working yet) to create an array, then looping through the array to pull out the data, Ideally I'd like to be able to loop through the Purchase Order Items Array Controller arrangedObjects, and then set strings like for each (object in Purchase Order Items Array Controller ){ qtyString = [[Purchase Order Items Array Controller arrangedObjects] valueForKey:@qty]; ... } (where qty is an attributes of the PurchaseOrderItems Entity but i don't think it works like that! -Ben Thanks for all your help though, Amy___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Key Paths @count and mutablestrings
Hi, Is there an easy way to access the existing Array Controller from the code? I have a suitable Array Controller called Purchase Order Items Array Controller in IB, but I don't see a way to reference this in the code. The Array Controller is bound to the selection of another Array Controller. As before and always, using IBOutlets ? You can connect an IBOutlet from any of your delegate/controller NSObject subclasses (the ones in defined in Xcode and filled with real code). If you have a NSAppDelegate class already at hand, create an IBOutlet NSArrayController *theWantedArrayController in the header file and connect that in IB to the appropriate object in IB. Volker ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Key Paths @count and mutablestrings
On 5 Nov 2008, at 5:28 am, Amy Gibbs wrote: I can connect it in IB, my problem is how to reference it / use the objects in it in the code. In IB I already have the Array Controller called Purchase Order Items. If you have an IBOutlet, let's call it 'myPurchaseOrderItems', you can see and connect it in IB, and simply refer to it in the code: [myPurchaseOrderItems doStuff]; Note that the identifier 'Purchase Order Items' is illegal - you can't have spaces in the identifier. Thus I wonder if you've run into a common misconception which is that the name you assign an object in IB has some relevance? It doesn't - it's just a label, inaccessible to your code. Instead, you declare the IBOutlets in your code just as a normal instance variable, but prefixed by 'IBOutlet': @interface MyClass : NSObject { IBOutlet NSArrayController* myPurchaseOrderItems; } @end Now if you drag a plain 'Object' into your IB window, set its class to 'MyClass', you'll see that it now has an outlet 'myPurchaseOrderItems' available for connection. You can ctrl-drag that to the object it represents. The icon label doesn't matter, it's just there to tell stuff apart (which is useful when you have a number of otherwise identical-looking icons in there) but of no use at runtime. There's no real magic about IBOutlet, it's just a macro that stands for nothing, but in IB that is detected and made available to the UI within IB. hth, Graham ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Key Paths @count and mutablestrings
Hi, I'm afraid I have a couple more questions :( Key Paths Bindings I've been quite sucessful in setting up my bindings using key paths, but now I'm trying to use @count. I have a table that displays a list of PurchaseOrders. 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. If I use Value: bound to Purchase Order Array Controller arrangedObjects orderReference I get the orderReference correctly. OrderReference is an attribute of the PurchaseOrder Entity. How do I access the count of a to-many relationship? Next Question... 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. 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? In this case, the content set of the Purchase Order Items Array Controller are bound to selection.products [Purchase Order Array Controller] I'd appreciate any help, Many Thanks Amy ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]