I have created a view loading to it toolbar with few 7 buttons.
I want to add action for each – thus each one will perform different action all of them will load view but according to the user selection of the button I will load to the view different screen i.e buttons etc..
Here is my loop:
int i =0;
for (NSString *items in array)
{
//Set button style
[barButton setStyle:UIBarButtonItemStyleBordered];
//Set the button title
[barButton setTitle:[array objectAtIndex:i]];
[barButton setAction:@selector(tmp:)];
//Add the bar button to the array - later will load the array to the tool bar items list.
[itemsArray insertObject:barButton atIndex:i];
i++;
}
As you see setAction is now activate tmp method – I want to take it from the name of the method from the NSString value of the array – ideas?
You can use
NSSelectorFromStringfunction. See here :http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Miscellaneous/Foundation_Functions/Reference/reference.html#//apple_ref/c/func/NSSelectorFromString