node ninja
node ninja

Reputation: 32986

IBActions foo and foo:

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?

Upvotes: 0

Views: 311

Answers (2)

tgunr
tgunr

Reputation: 1548

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];
}

Upvotes: 1

esqew
esqew

Reputation: 44706

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?

Upvotes: 2

Related Questions