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

petron

macrumors member
Original poster
May 22, 2009
95
0
Malmo, Sweden
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
 
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
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.