Dear all
I have a code like this:
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
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