[MacRuby-devel] NSArrayController
Richard Kilmer
rich at infoether.com
Thu Sep 25 19:59:05 PDT 2008
On Sep 25, 2008, at 10:40 PM, Laurent Sansonetti wrote:
> Hi Brad,
>
> On Sep 25, 2008, at 6:29 PM, Brad Wilson wrote:
>
>> Hi,
>>
>> Is it possible to use bind values using macruby?
>>
>> I've been working through Hillegass' Cocoa Programming For Mac OS X,
>> converting the exercises to MacRuby.
>>
>> I've hit a big of a snag in the RaiseMan exercise though. It uses an
>> NSArrayController as a binding for a table view. There is then a
>> NSDocument called Person which is bound to provide the values for
>> the table.
>>
>> When I try to run this, I'm getting an error:
>> this class is not key value coding-compliant for the key employees
>>
>> I've tried a number of different ways to make employees respond:
>> attr_accessor :employees
>> and also using a manual setter (in two different ways):
>> def employee=(val) end
>> def setEmployee(val) end
>>
>>
>> Neither seem to work. Am I doing something wrong? Is this
>> unimplemented?
>
> I never really tried to use NSArrayController in MacRuby, but I know
> that Rich uses it in HotCocoa and it seems to work well. And it's
> certainly possible to use bindings in MacRuby.
Here's an example of a key binding for an item that is an
NSCollectionViewItem (thus representedObject)
image.bind "value", toObject:item,
withKeyPath:"representedObject.user.profile_image", options:nil
So I am binding the value of the image to the item object's keypath:
representedObject.user.profile_image
It looks like its complaining that the array of objects that you are
placing in ArrayController is causing
and exception that it is not KVC compliant?
As Laurent indicated, if you post what you have we might be able to
help.
Best,
Rich
>
>
> Could you upload your code somewhere so that we can have a look at it?
>
> Also, it's great that you're converting the book exercises to MacRuby.
> If you are willing to contribute them after, I would be glad to
> package them in the distribution :-)
>
> Laurent
> _______________________________________________
> MacRuby-devel mailing list
> MacRuby-devel at lists.macosforge.org
> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
More information about the MacRuby-devel
mailing list