image
image

Go Back   macosx.com > Design, Media, Programming & Scripting > Software Programming & Web Scripting

Reply
 
LinkBack Thread Tools
  #1  
Old July 25th, 2001, 01:08 PM
rharder's Avatar
Do not read this sign.
 
Join Date: Mar 2001
Location: Virginia, USA
Posts: 1,188
Thanks: 0
Thanked 2 Times in 2 Posts
rharder is on a distinguished road
What's an IBAction?

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
__________________
There are only 10 kinds of people in the world:
Those who understand binary, and those who don't.
Reply With Quote
  #2  
Old July 25th, 2001, 01:31 PM
endian's Avatar
Dis Member
 
Join Date: Sep 2000
Location: inside my skin
Posts: 960
Thanks: 0
Thanked 0 Times in 0 Posts
endian is on a distinguished road
Quote:
I don't return anything from these methods, but could I?
Nope, IBAction is defined as void. It's just there so IB can parse your header when you drag it into IB.
__________________
g4 400 AGP - 512 RAM
10GB internal (dumping ground) + 60GB (30 GB OSX partition/30 GB OSX Server partition) - 3GB external SCSI (OS9/and I think the Public Beta is still on there somewhere) - DVD-RAM - ZIP

Reply With Quote
  #3  
Old July 25th, 2001, 03:54 PM
rharder's Avatar
Do not read this sign.
 
Join Date: Mar 2001
Location: Virginia, USA
Posts: 1,188
Thanks: 0
Thanked 2 Times in 2 Posts
rharder is on a distinguished road
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
__________________
There are only 10 kinds of people in the world:
Those who understand binary, and those who don't.
Reply With Quote
  #4  
Old July 25th, 2001, 04:28 PM
endian's Avatar
Dis Member
 
Join Date: Sep 2000
Location: inside my skin
Posts: 960
Thanks: 0
Thanked 0 Times in 0 Posts
endian is on a distinguished road
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.
__________________
g4 400 AGP - 512 RAM
10GB internal (dumping ground) + 60GB (30 GB OSX partition/30 GB OSX Server partition) - 3GB external SCSI (OS9/and I think the Public Beta is still on there somewhere) - DVD-RAM - ZIP


Last edited by endian; July 25th, 2001 at 04:41 PM.
Reply With Quote
  #5  
Old July 26th, 2001, 02:36 PM
rharder's Avatar
Do not read this sign.
 
Join Date: Mar 2001
Location: Virginia, USA
Posts: 1,188
Thanks: 0
Thanked 2 Times in 2 Posts
rharder is on a distinguished road
I was wondering if I could use an IBAction method by invoking a selector at run-time which is a trick I'm trying with the ThreadWorker class (http://iharder.net/macosx/threadworker).

I'm away from any NS*-capable compiler for a while, so I can't experiment.

-Rob
__________________
There are only 10 kinds of people in the world:
Those who understand binary, and those who don't.
Reply With Quote
  #6  
Old July 26th, 2001, 06:52 PM
endian's Avatar
Dis Member
 
Join Date: Sep 2000
Location: inside my skin
Posts: 960
Thanks: 0
Thanked 0 Times in 0 Posts
endian is on a distinguished road
you can invoke it at runtime, you just can't return anything.

e.g. [window makeKeyAndOrderFront:nil];
__________________
g4 400 AGP - 512 RAM
10GB internal (dumping ground) + 60GB (30 GB OSX partition/30 GB OSX Server partition) - 3GB external SCSI (OS9/and I think the Public Beta is still on there somewhere) - DVD-RAM - ZIP

Reply With Quote
  #7  
Old July 27th, 2001, 09:38 PM
rharder's Avatar
Do not read this sign.
 
Join Date: Mar 2001
Location: Virginia, USA
Posts: 1,188
Thanks: 0
Thanked 2 Times in 2 Posts
rharder is on a distinguished road
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
__________________
There are only 10 kinds of people in the world:
Those who understand binary, and those who don't.
Reply With Quote
Reply

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Forum Jump


All times are GMT -5. The time now is 09:02 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0 RC1
Copyright 2000-2010 DigitalCrowd, Inc.