From: Jonathan P. <jp...@dc...> - 2005-06-04 20:38:31
|
On 4 Jun 2005, at 20:37, Dave Howell wrote: > My outlets were named things like "taskDue," "taskTitle," and > "taskDescription," and when I added the actions, I named them > "setTaskDue," "setTaskTitle," and "setTaskDescription." Xcode or IB > or Cocoa or I-don't-know-who's-fault-this-is obviously decided they > were related in some way and broke everything for me. There's a convention that means that rather than directly change the instance variable in your class, if there's a method named 'setSomeName' where 'someName' is the name of the instance variable, it'll get used instead. This is the Key-Value Coding system used in Cocoa Bindings. Read more here: http://developer.apple.com/documentation/Cocoa/Conceptual/ CocoaBindings/CocoaBindings.html Specifically, see the documentation for the setValue:forKey: method: http://developer.apple.com/documentation/Cocoa/Reference/Foundation/ ObjC_classic/Protocols/NSKeyValueCoding.html#//apple_ref/doc/uid/ 20000471-BABEHECF > I have gone back and put my outlets back in with names that can't > be matched up, and now things work properly. I have no idea where > I'd even find this "feature" documented. Sigh. Caveat Programmeri. I usually name my outlets indicating what they're connected to - for example: "taskTitleField". It's worth taking a look at Cocoa Bindings. They don't solve every situation, but for the situations they're designed for they make life very easy. A little extra support code is needed in RubyCocoa to make them work (see http://rubycocoa.sourceforge.net/w.en/FAQ.html and my previous posts to the list on the matter). I'm afraid, however, that it's probably worth working through the one of the Objective C examples first. |