What's an IBAction?

rharder

Do not read this sign.
A method that's called as an action from Interface Builder has the signature
- (IBAction)actionName: (id)sender.

What's an IBAction? Is it an object (an id)? A constant?

I don't return anything from these methods, but could I?

-Rob
 

rharder

Do not read this sign.
If I have an IBAction method, will its return value be nil if I do something like this:
Code:
id obj = [self buttonPressed:self];
-Rob
 

endian

Dis Member
i doubt that'd even compile.. it'll probably say something like 'assigning void value should be ignored.' void isn't nil, it's just nothing.

not sure what you're trying to do, but you can differentiate between multiple buttons calling the same action with the tag instance variable - give each button a unique tag value, then do something like
Code:
-(IBAction)buttonPressed:(id)sender
{
	switch ( [sender tag] )
	{
	case 1:
	//blah blah blah
	break;

	case 2:
	//blah blah etc.
	break;
	}
}
You could obviously call your own methods and return whatever you want from there.
 

endian

Dis Member
you can invoke it at runtime, you just can't return anything.

e.g. [window makeKeyAndOrderFront:nil];
 

rharder

Do not read this sign.
So I finally got back to my OS X box, and yes, you can set a variable equal to the return value of a method that returns void (or at least, IBAction). Essentially, you're setting the variable to nil. That's not a problem.

-Rob
 
Top