How to debug where the action from a button is going ?

Discussion in 'Mac Programming' started by petron, Sep 20, 2009.

  1. petron macrumors member

    Joined:
    May 22, 2009
    Location:
    Malmo, Sweden
    #1
    I am making a HilleGass Chapter 31 and all seems to be fine so far, but right now I stopped on the fact that an IBAction has method does not receive the event from the Button when the button is pressed

    In the PolView.h file I have

    Code:
    #import <Cocoa/Cocoa.h>
    
    @interface PolynomView : NSView {
        NSMutableArray *polynomials;
    }
    - (IBAction)createNewPolynom:(id)sender;
    - (IBAction)deleteRandomPolynom:(id)sender;
    @end
    
    then in the PolView.m file

    Code:
    - (IBAction)createNewPolynom:(id)sender {
        polynom *p = [[polynom alloc] init];
        [polynomials addObject:p];
        [self setNeedsDisplay:YES];
    }
    
    - (IBAction)deleteRandomPolynom:(id)sender {
        if ([polynomials count] == 0) {
            NSBeep();
            return;
        }
        int i = random() % [polynomials count];
        [polynomials removeObjectAtIndex:i];
        [self setNeedsDisplay:YES];
    }

    I have connected the two Buttons into the visible actions in the PolView in the InterfaceBuilder one to createNew... and one to the deleteRan..., but I do not see any action been initiated when pressing the buttons.

    I wonder if there is a possibility to see in the debugger what is going on ???

    Thanks for a tip in advance..
    /petron
     
  2. petron thread starter macrumors member

    Joined:
    May 22, 2009
    Location:
    Malmo, Sweden
    #2
    Hm...
    I played a bit with buttons, but with no help. Then I run "Build - Clean", build it again and now the IBAction get called.
    I am a bit confused. I really do not know what has happened.:confused:

    Even if it works now it could be good to get a tip how to debug the button actions in case the events do not arrive where they should.

    I am using Xcode 3.2 on SL. 10.6.1

    GL
    /petron
     

Share This Page