Okay, all I am trying to do is setup a counter that will add 1 everytime a button is pressed on the iPhone screen. I have two buttons total, both execute the "buttonPressed" method. If I do a "+= 1" on overallCount as a local variable it's fine. If I do a "+= 1" as in the code below, overallCount in increased to 4, then 8, then 12, and so on. What the heck am I doing wrong?
Code:
#import <UIKit/UIKit.h>
@interface RL_GLViewController : UIViewController {
IBOutlet UIButton *leftButton;
IBOutlet UIButton *rightButton;
NSInteger *overallCount;
}
@property(nonatomic, retain) IBOutlet UIButton *leftButton;
@property(nonatomic, retain) IBOutlet UIButton *rightButton;
@property(nonatomic, assign) NSInteger *overallCount;
-(IBAction) buttonPressed:(id) sender;
@end
#import "RL_GLViewController.h"
@implementation RL_GLViewController
@synthesize leftButton;
@synthesize rightButton;
@synthesize overallCount;
-(IBAction) buttonPressed:(id) sender{
overallCount += 1;
NSLog(@"%d", overallCount);
}
- (void)dealloc {
[leftButton dealloc];
[rightButton dealloc];
[super dealloc];
}
@end