Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

stece

Guest
Original poster
Oct 9, 2008
11
0
Dear all
I have a code like this:

Code:
#import <Cocoa/Cocoa.h>


@interface Clasa : NSObject {
	IBOutlet NSTextField *textField;
}
-(IBAction)seed:(id)sender;
-(IBAction)generate:(id)sender;
@end
---------------------------------------------
#import "Clasa.h"


@implementation Clasa
- (IBAction)generate:(id)sender
{
	int generated;
	generated = (random()% 100) + 1;
	NSLog(@"generated = %d", generated);
	[textField setIntValue:generated];
}
- (IBAction)seed:(id)sender
{
	srandom(time(NULL));
	[textField setStringValue:@"Generator seeded"];
}

@end

and how does the computer know that if I push the button it is to
show the int generated. I mean how does he know it in the function of time ( namely how does he know when to do it) because there is no mouseclick event defined or anything similar. So which event punctuates it and how?
I read there are some actions, but how do these actions refer to the mouse click or push of the button?

Thank you in advance
 

SydneyDev

macrumors 6502
Sep 15, 2008
346
0
The button object stores in it's member variables a pointer to another object, and the name of a method to call on that object when it is clicked.

In Interface Builder, you create an instance of your object (above) and drag a line from the button to your object to set these member variables. The settings you make here are saved in the Interface Builder XIB file and restored at runtime.
 

stece

Guest
Original poster
Oct 9, 2008
11
0
About using Apple documantation

The button object stores in it's member variables a pointer to another object, and the name of a method to call on that object when it is clicked.

How to know from reference library of the NSButton which member variables are pointers to another object, and how to know which method they call if I click the button ?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.