I have i IBAction and it’s connected with a button in .xib. But for a action o needed this code;
- (void) reportScore: (int64_t) score forCategory: (NSString*) category
{
GKScore *scoreReporter = [[GKScore alloc] initWithCategory:category];
scoreReporter.value = counter;
[scoreReporter reportScoreWithCompletionHandler: ^(NSError *error)
{
[self callDelegateOnMainThread: @selector(scoreReported:) withArg: NULL error: error];
NSLog(@"Nice: %d", counter);
}];
}
Is there a way to connect my button with the void? Or something like that?
- (IBAction) subScore {
//data
}
IBAction(andIBOutlet) is just used to let XCode’s Interface Builder(IB) know that there’s a function exist. If you want usevoid, okay, but you’ll not get the function shown in Interface Builder.You can set the function(which is defined with
void, and noteIBActionis okay either, but needless here) to your button target like this:Generally, if you create your code programmatically(without using XCode’s Interface Builder), you do not need
IBOutletorIBActionanymore. 😉