Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Aarend

macrumors newbie
Original poster
Mar 1, 2014
1
0
Hi, i'm using Xcode version 5.0.2. To set a target from a button i have to Control-drag this button from the canvas to File's Owner. File's Owner will then highlight. For no reason this doesn't work and i can't find a way to make this happen, what am i doing wrong? :(
 

xStep

macrumors 68020
Jan 28, 2003
2,031
143
Less lost in L.A.
First, in you source file, usually the .h file, you need a line like the following. This is from MyClassViewController.h file.

Code:
- (IBAction) tapTheButton: (id) sender;

The attached image displays that the File's Owner needs to be of the class your dealing with. Look to the right.
 

Attachments

  • SampleXC5-IBOutlets.jpg
    SampleXC5-IBOutlets.jpg
    40.8 KB · Views: 81

Duncan C

macrumors 6502a
Jan 21, 2008
853
0
Northern Virginia
Hi, i'm using Xcode version 5.0.2. To set a target from a button i have to Control-drag this button from the canvas to File's Owner. File's Owner will then highlight. For no reason this doesn't work and i can't find a way to make this happen, what am i doing wrong? :(

It only works if you already have IBActions declared in your header file.

The better thing to do is to open an assistant editor to the view controller's header file, and control-drag from the button into the header. You will be presented with a popover that lets you create an outlet or an action. It defaults to creating an outlet. You have to switch the popup to action, set it to make the sender's type UIButton instead of id, and name the action. When you do this, it does 3 things in one:

  1. It creates the IBAction method definition in the header.
  2. It creates an empty IBAction in the .m file
  3. It connects an IBAction link to the action method in the interface file.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.