-(void)displayNameBy:(NSString*)name{
mylable.text = name;
}
i want call this method using @selector keywords.
eg:
If you create a one-argument selector for your action (like you're doing in displayNameBy:
), the argument is the sender of the action. In this case, your button instance.
According to the UIControl docs, there are three different types of supported selectors:
- (void)action
- (void)action:(id)sender
- (void)action:(id)sender forEvent:(UIEvent *)event
Where are you expecting name
to be defined? Is it based on the user's actions, the app state, or something else? Depending on what method is used, you could create a UIButton subclass that includes either the necessary logic or declares a delegate protocol, set the delegate to your view controller, and have the delegate implementation set the button's label. The latter is probably better from a MVC standpoint, unless the source of name
is blindingly simply (ie, an attribute that could be set on the button, not something the button would have to calculate based on other application state).