Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > simple newbie developer question

simple newbie developer question
Thread Tools
Professional Poster
Join Date: Oct 2001
Status: Offline
Reply With Quote
Jan 16, 2002, 02:57 PM
 
k, im learning cocoa, and i have two questions:
the first is simple, can i just use void all the time instead of IBAction?

like instead of:

- (IBAction)generate id)sender

i'll put

- (void)generate id)sender

can i use void all the time?

also, what is the (id)sender part? what does it mean? does it have to be "sender", or can i put anything?

sorry for my newbieness

edit: the unhappy faces are there because i put ":" and "(" together, so where you see unhappy faces it's just a colon and an opening parentheses

[ 01-16-2002: Message edited by: itistoday ]
     
Mac Elite
Join Date: Sep 2000
Location: Eagan, MN
Status: Offline
Reply With Quote
Jan 16, 2002, 06:25 PM
 
Sender is just used to tell a function who called the function (what object). Just pass "self" along for a function call:

[mainInterface generate:self];

You could call the variable something else, but there's no point (It wouldn't change anything).
     
Addicted to MacNN
Join Date: Mar 2000
Location: London, UK
Status: Offline
Reply With Quote
Jan 18, 2002, 04:22 PM
 
Originally posted by itistoday:
<STRONG>k, im learning cocoa, and i have two questions:
the first is simple, can i just use void all the time instead of IBAction?</STRONG>
Yes. From NSNibDeclarations.h:

<BLOCKQUOTE><font size="1"face="Geneva, Verdana, Arial">code:</font><HR><pre><font size=1 face=courier>#ifndef IBAction
#define IBAction void
#endif</font>[/code]

So IBAction _IS_ void.
     
Grizzled Veteran
Join Date: Apr 2001
Status: Offline
Reply With Quote
Jan 19, 2002, 08:56 PM
 
But why would you want to define IBAction as void?

Wade
     
Grizzled Veteran
Join Date: Feb 2001
Location: Germany
Status: Offline
Reply With Quote
Jan 20, 2002, 08:46 AM
 
Originally posted by wadesworld:
<STRONG>But why would you want to define IBAction as void?
</STRONG>
well, you somehow got to give ib a clue which methods to display in "connections" and which not.
whenever a project grows and you figure that you need additional gui elements, just drag your .h into ib and it'll show your new ibactions so you can connect them. it would be horrible if all your methods appeared in there, that would be a real mess.

[ 01-20-2002: Message edited by: seb2 ]
     
   
Thread Tools
Forum Links
Forum 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 On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 09:44 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2