From: hvs1@... (Harry) Date: 2004-07-08T15:42:35+09:00 Subject: Re: [RubyCocoa] Cocoa Bindings? (cont.) Dan Tapp wrote in message news:... > I'm kind of flying blind here, but from what I remember about Apple's > KeyValueCoding protocol, it's only necessary to implement a couple of > methods. In more-or-less Obj-C form (I'm rusty), the first two are > > - (id)valueForKey: aKey > - (void *)takeValue: someValue forKey: someKey Yes, they are part of the NSKeyValueCoding protocol and should be implemented by the base-class NSObject, as described on Apple's ADC site: 'Key-value coding in Objective-C is largely managed by the NSKeyValueCoding informal protocol, which is implemented by the NSObject class.' > In other words, KVC is designed to circumvent setFoo/getFoo methods, not > to require them. And (also on that site (I'm not sure the urls for that site are persistent, so I'll just quote the text)): 'In order for a class to be considered KVC compliant for a specific property, it must implement the methods required for valueForKey: and setValue:forKey: to work for that property. For properties that are an attribute or a to-one relationship, this requires that: * Your class implements a method named -, -is, or have an instance variable or _. * If the property is mutable, then it should also implement -set:. * Your implementation of the -set: method should not perform validation. * Your class should implement -validate:error: if validation is appropriate for the key.' > There is, IIRC, at least one other method needed for strict compliance, > somthing to do with handling unbound (unrecognized) keys, but I can't > remember the precise name or use. I think on the Foundation Kit side, > Apple may still include some default KVC behavior to relieve you from > the need of implementing this. > > Also, you might make sure that you're passing in first-class objects (as > Obj-C defines them, meaning non-scalars). Earlier versions of > Foundation Kit permitted a mixed approach, depending on the type of the > ivar, but I do believe that later, Java-based versions standardized on > wrapped primitives. Can you elaborate on that? I'm rusty in language intrinsics ... > I hope at least some of that is useful, and wish I had Cocoa + Ruby to > fiddle with these days :-) Thx for answering Dan! Yep, same here, alas it doesn't get much further then fiddling right now ... pretty much stuck with the combined RubyCocoa + Cocoa Bindings thing, which I believe is the best thing since sliced bread ... ;) Harry