PDA

View Full Version : [Resolved] Using a void within an IBAction




lRetro
May 23, 2011, 06:23 PM
So I'm making a simple application that acts on a button. There are 8 other buttons in a circle and when the button is pressed each button for 60 milliseconds will disable and then re-enable in order, so it looks like it makes a circle.

All the logic for the enabling/disabling are in "void" functions, but it seems that I cannot call that function within an IBAction..

Is it possible to do so? I've been googling around and I haven't seen anything like it.

Example:
- (IBAction) activateButton:(id)sender{
void beginCircleBusy();
}

- (void) beginCircleBusy:(id)sender{
firstButton.enabled = NO;
[NSTimer scheduledTimerWithTimeInterval: .06 target:self selector:@selector(goToSecondButton:) userInfo: nil repeats:NO];
}

and so on..

Note: What HAS worked was associating that function using the Interface Builder to the button.. but I was just wondering if I can do this with code instead of the GUI and I want to use other functions after the function finishes.

Any helps appreciated! :3

-Retro



nickculbertson
May 23, 2011, 07:27 PM
change

- (void) beginCircleBusy:(id)sender{

to

- (void) beginCircleBusy{

then in your IBAction

[self beginCircleBusy];


Nick

jnoxx
May 24, 2011, 03:51 AM
Like the guy said above me, you can call an action from your own class, or another class tha thas been inited/stored in memory.

by just calling [self classMethodName]; which u can give parameters etc.
or for example [secondController classMethodName]; if your secondController pointer is inited. kind off.

Gz

lRetro
May 24, 2011, 01:20 PM
change

- (void) beginCircleBusy:(id)sender{

to

- (void) beginCircleBusy{

then in your IBAction

[self beginCircleBusy];


Nick

Like the guy said above me, you can call an action from your own class, or another class tha thas been inited/stored in memory.

by just calling [self classMethodName]; which u can give parameters etc.
or for example [secondController classMethodName]; if your secondController pointer is inited. kind off.

Gz

Thanks! It worked :3

MSP4444
May 29, 2011, 04:36 AM
So how would you use this method to point the embedYouTube function to an IBAction...?

- (void)embedYouTube:(NSString *)urlString frame:(CGRect)frame {

Any ideas?

nickculbertson
May 29, 2011, 07:53 AM
Try this.

[self performSelector:@selector(embedYouTube:) withObject:nil afterDelay:0.01];