I am creating a list of bar buttons with its action functions (sFuncName
as below), it is dynamically changed.
When user clicks on a button, sFuncName
will be called.
for(int i = 0; i < 3 ; i++){
NSString* sFuncName = [NSString stringWithFormat:@"OnFunc_%d:", i ];
barButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:systemItem target:self
action:NSSelectorFromString(sFuncName)];
}
The question is: have I got any way to dynamically declare sFuncName
to respond to buttons?
Example:
for(int i = 0; i < 3 ; i++){
NSString* sFuncName = [NSString stringWithFormat:@"OnFunc_%d:", i ];
- (void)sFuncName: (id)sender; //sFuncName: OnFunc_0, OnFunc_1, OnFunc_2
}