Reputation: 1099
I need to call a method I have defined as:
-(IBAction)next:(id)sender{
...
}
I want to call it in -[UIViewController viewDidload]
How can I call this method programmatically?
Upvotes: 5
Views: 6254
Reputation: 523214
[self next:nil];
self
is the object receiving the message, assuming -next:
is defined in the same class as -viewDidLoad
.next:
is the name of the message (method).sender
, pass the argument nil
, meaning "nothing".If -next:
is defined in the App delegate but -viewDidLoad
in some view controller, use
[UIApplication sharedApplication].delegate
to refer to the app delegate. So the statement becomes
[[UIApplication sharedApplication].delegate next:nil];
Upvotes: 11