That little ditty just saved me a ton of time and made it a cinch to connect the view in Interface Builder to the controller in Xcode. It wasn't entirely obvious until I saw it in one of the project templates and tried to make sense of it myself.
In other words, place this in your ViewController header file (ViewController.h)
& draw up your method in the implementation (ViewController.m) like so:
Quote:
- (IBAction)methodName {doSomething; }
|
Save the header and implementation files, then open the respective XIB file. Right-click on a button, slider, or whatever to bring up the list of events it catches (e.g. for buttons, the default is Touch Up Inside). Drag from the circle on the right over to File's Owner in the XIB folder window. It should bring up another little window in which you can select the action you just made. Then whenever that action is performed on the control, your action code will be performed. Also found that right-click-dragging straight from the control in question over to File's Owner will pick that control's most likely desired default event. Note: File's Owner should expect to be set to an instance of your specific ViewController, otherwise it won't know what actions you've made possible in your code. This is how it's set up by default if you pick one of the template applications like Flipside, etc.; but otherwise, you can make sure of it by going to the right-most tab on Inspector, and at the top, give it an appropriate class name to expect.
That was the missing link for me when I tried playing with the earlier betas of the SDK - I couldn't quite figure out how to drag and drop to link things up, and this just saved me a ton of time on a concept UI that I whipped up real quick.
Sorry I don't have screenshots to show at the moment, the computer it's on isn't connected to the net