How to I initialize a class with an interface button clicked? [Objective - C]
- by seaworthy
I am having a problem with figuring out how to initialize a class with button clicked. The code is listed below the line I have a problem with has "HELP NEEDED HERE" comment above it.
//
// Controller.m
//
#import "Controller.h"
@implementation Controller
- (id)init {
self = [super init];
if(self){
numberTotal = 0;
//HELP NEEDED HERE
[self btnScore_Clicked:(id)sender];
}
return self;}
- (IBAction) btnScore_Clicked:(id)sender {
numberTotal += 1;
NSLog(@"Number Total: %d",numberTotal);
}
- (void)dealloc {
[super dealloc];
}
@end
//
// Controller.h
//
#import <UIKit/UIKit.h>
@interface Controller : UIViewController {
NSInteger numberTotal;
}
- (IBAction) btnScore_Clicked:(id)sender;
@end
Thanks!