On 05/04/2011, at 7:26 AM, Carlos Eduardo Mello wrote:

> I am new to this but, (just in case...) have you, by any chance, named a 
> function in your delegate as a setter for your outlet (setTextField:)? I fell 
> into that trap a little while ago:  -awakeFromNib is called before the outlet 
> is connected and it never gets wired to the nib.

That's not what was happening, but you may be on to something.

If you name an outlet 'textField', then the nib loading machinery will look for 
a method called -setTextField: in order to wire the outlet. That's probably 
going to fail in quite a few cases because the name is far too generic and it's 
not unlikely that a method called -setTextField: exists that has nothing to do 
with said outlet. The wiring up will fail if that method does not in fact 
simply assign the outlet.

It's a really good idea to name your outlets in some fashion that indicates 
both their type and their function. If nothing else it makes identifying them 
in IB easier, for example, a good name might be  'mCountOfWidgetsTextField'.

This name tells you a) that it's a data member of the class - 'm' for member, 
b) that it represents 'countOfWidgets' and c) that it is expected to be a text 
field. It also means that accidentally misleading the nib loader is far less 
likely.

It's certainly worth trying a better, less generic name and see if that fixes 
your issue.


--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 arch...@mail-archive.com

Reply via email to