вы можете передать один из них как свои пользовательские данные, сохраняя программу безопасной для переводов c ++:
/* include the necessary C header, located in objc/ (objc/objc.h?) */
/* of course, definitions with objc messaging belong in your .mm file */
class t_ibaction_invocation {
/* you may want to retain d_target or d_optionalArgument, and release at destruction */
enum { RetainArguments = 0 };
public:
/* IBAction takes the form: [target action:optionalArgument]; */
t_ibaction_invocation(id target, SEL action, id optionalArgument) : d_target(target), d_action(action), d_optionalArgument(optionalArgument) {
assert(this->d_target);
if (RetainArguments) {
[this->d_target retain];
[this->d_optionalArgument retain];
}
}
~t_ibaction_invocation() {
if (RetainArguments) {
[this->d_target release], target = 0;
[this->d_optionalArgument release], optionalArgument = 0;
}
}
id performAction() {
if (this->d_target && this->d_action) {
return [this->d_target performSelector:this->d_action withObject:this->d_optionalArgument];
}
else {
assert(d_target && d_action);
return 0;
}
}
private:
id d_target;
SEL d_action;
id d_optionalArgument;
};