Resolved Using a void within an IBAction

Discussion in 'iOS Programming' started by lRetro, May 23, 2011.

  1. lRetro, May 23, 2011
    Last edited: May 24, 2011

    macrumors newbie

    Joined:
    May 23, 2011
    #1
    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:
    Code:
    - (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
     
  2. macrumors regular

    nickculbertson

    Joined:
    Nov 19, 2010
    Location:
    Nashville, TN
    #2
    change
    Code:
    - (void) beginCircleBusy:(id)sender{
    
    to
    Code:
    - (void) beginCircleBusy{
    
    then in your IBAction
    Code:
    [self beginCircleBusy];
    
    Nick
     
  3. macrumors 65816

    jnoxx

    Joined:
    Dec 29, 2010
    Location:
    Aartselaar // Antwerp // Belgium
    #3
    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
     
  4. thread starter macrumors newbie

    Joined:
    May 23, 2011
    #4
    Thanks! It worked :3
     
  5. macrumors newbie

    Joined:
    May 29, 2011
    #5
    So how would you use this method to point the embedYouTube function to an IBAction...?

    Code:
    - (void)embedYouTube:(NSString *)urlString frame:(CGRect)frame {
    Any ideas?
     
  6. macrumors regular

    nickculbertson

    Joined:
    Nov 19, 2010
    Location:
    Nashville, TN
    #6
    Try this.
    Code:
    [self performSelector:@selector(embedYouTube:) withObject:nil afterDelay:0.01];
    
     

Share This Page