【发布时间】:2012-01-07 07:44:09
【问题描述】:
我有 i IBAction,它与 .xib 中的一个按钮相连。但是对于一个动作需要这个代码;
- (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);
}];
}
有没有办法将我的按钮与 void 连接起来?或者类似的东西?
- (IBAction) subScore {
//data
}
【问题讨论】:
-
void 和 IBAction 是一回事。 IBAction 只是头文件的一个标记,告诉 IB 一个动作可以连接到方法。
标签: objective-c ios interface-builder ibaction