views:

45

answers:

2

In Interface Builder I in Library->Classes when I select a class that I made in XCode, then display the Actions, I can see two with the same name:

foo
foo:

What is the difference between these two foos?

+2  A: 

foo is a method that doesn't accept any arguments. foo: passes an argument or arguments into its method.

Example:

-(IBAction)foo;

will be shown as foo in IB.

-(IBAction)foo:(id)sender;

will be shown as foo: in IB.

I don't know why they have the same name, do you have them set that way?

esqew
I made one in IB and then I went in XCode and made another one so that I could write the implementation of it.
awakeFromNib
+1  A: 

IB assumes if your creating the class files using IB that you will using the sender and so it creates the construct

-(IBAction)foo:(id)sender;

You usually will need info about the sender so I would stick with that construct. If you don't need the sender in your implementation, simply ignore it.

-(IBAction)foo:(id)sender {
    [someObject doAMethod];
}
tgunr