views:

47

answers:

2

Hello,

I have the following code:

@interface AddResident : UIViewController
{
    IBOutlet UITextField *FirstName;
    IBOutlet UISegmentedControl *Gender;
}

I can see both of these outlets in interface builder but can only connect the UISegmented control... the other one will not connect to my UITextField on the form.

Any help is much appreciated.

+1  A: 

Two possibilities:

1) You're trying to link to the textfieldCELL instead of the textfield. (which has a cell inside of it)

2) you need to bind it instead of connect it.

The way that I have done this (With NSTextFields, but I can't imagine it's all that different) was to bind the textField to a property (Not necessarily IBOutlet) in my controller. Actually, in one case, the property doesn't even actually exist, but I have what look like getter and setter methods that do the correct things...

Brian Postow
Actually bindings work with anything that is Key-Value Coding and Key-Value Observing compliant. It so happens that properties are KVC/KVO compliant but property declaration or even get/setters are not necessary. You can actually bind directly to a private instance variable, though it's not recommended.
invariant
A: 

It should. Did you make sure that you are not trying to connect to UITextView? Maybe restarting XCode will help also...

Denis M