views:

196

answers:

1

I have a UITextField that has been added to my view in Interface Builder. My question is: is there a way I can programatically set its delegate from within Xcode? I know that I can connect up the delegate in IB by dragging a connection from UITextField>Delegate to my viewController which implements textFieldShouldReturn:

Just curious as the control "UITextField" is obviously instantiated in IB and not directly through code.

cheers Gary

+1  A: 

If you've got an IBOutlet to it, just use:

[theTextField setDelegate:aDelegate];
Tom Irving
Thank you, I did have an IBOutlet so thats just what I needed. Just a side note to anyone else I also needed to conform my interface to the UITextFieldDelegate protocol. It looks like you don't need that if you do the linking in IB.
fuzzygoat