Re: Missing connection
Re: Missing connection
- Subject: Re: Missing connection
- From: Matt Neuburg <email@hidden>
- Date: Tue, 4 Jan 2011 08:44:25 -0800
On Jan 3, 2011, at 8:35 PM, John Brownie wrote:
> On Tue Jan 04 2011 13:56:58 GMT+1000 (PGT) Matt Neuburg wrote:
>
>> You don't have a method called setStickyModifiers:, do you? If so, it will be called at nib-loading time with the button instance as parameter. When an instance variable isn't set to the instance pointed to by the corresponding outlet in the nib, this sort of thing is sometimes the cause... m.
>
> Thanks, that was it! Still wrapping my mind about the automatically generated names. I had a problem last week by calling a window Inspector, which apparently caused it to fail to load, as renaming it fixed things. Plenty of traps for those of us new to Cocoa...
>
This is a frequently encountered trap among newbies, though once bitten one tends to remember forever. :) An outlet name is just a string, whereas an object is, uh, a thing. To translate from a string to a thing, Cocoa uses key-value coding. Key-value coding seeks an appropriately named method before it seeks an appropriately named instance variable directly. For a setter, "appropriately named" means the name of the method starts with "set". You might have very good reason to take advantage of this feature - e.g. you might *want* the button handed to setStickyModifiers:, so that you can do something of your own with it. It's just that in this case, you didn't. You wanted it assigned directly to the instance variable. So you mustn't put an appropriately named setting in the way.
This particular case follows a predictable rule; the real problem arises when you accidentally use an undocumented already-existing name. I encountered a case like that just a few weeks ago:
<http://www.cocoabuilder.com/archive/cocoa/296662-assign-property-behaves-differently-from-simple-instance-variable.html>
Your case with Inspector may have been more like that (I'm not sure).
m.
--
matt neuburg, phd = email@hidden, http://www.tidbits.com/matt/
pantes anthropoi tou eidenai oregontai phusei
Among the 2007 MacTech Top 25, http://tinyurl.com/2rh4pf
AppleScript: the Definitive Guide, 2nd edition
http://www.tidbits.com/matt/default.html#applescriptthings
Take Control of Exploring & Customizing Snow Leopard
http://tinyurl.com/kufyy8
RubyFrontier! http://www.apeth.com/RubyFrontierDocs/default.html
TidBITS, Mac news and reviews since 1990, http://www.tidbits.com
_______________________________________________
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