Question

When connecting a UI object to an outlet using Interface Builder's drag and drop functionality, what code is generated to describe that connection? Which file contains the code? What about IBAction connections?

Was it helpful?

Solution

Interface Builder does not generate Objective-C code, though the things you are talking about can be done in code. IB creates XML files (.xib) which are compiled to binary .nib files.

Connections to UI outlets simply represent assignment to properties or ivars.

Connections of events to actions can be created with code. If you have an IBAction on object foo that you want to be triggered by UIButton *bar's Touch Up Inside event, you would do the following:

 [bar addTarget:foo
      action:@selector(tappedButton:)
      forControlEvents:UIControlEventTouchUpInside];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top