Reputation: 4746
Here is the method I wish to call:
- (void)myMethod:(id)sender {
How would I call it? I tried:
[self myMethod]
^error: Expected Expression before "]" token.
I know this is a simple question, but I am new to iPhone Development
Upvotes: 3
Views: 7495
Reputation: 22305
Unless you wanted to send an unspecified-type object to your method you don't need the (id)sender
portion:
- (void)myMethod {
}
Upvotes: 4
Reputation: 29524
You need to pass along a sender when you call it.
[self myMethod:something]
In other words, you need to have an argument to pass along when you call the method.
Upvotes: 1
Reputation: 78363
The method takes one parameter, so you have to give it one. If you have no sender you want to give, just pass nil:
[self myMethod:nil];
You could also overload the method as a convenience:
// declarations
- (void)myMethod;
- (void)myMethod:(id)sender;
// implementations
- (void)myMethod { [self myMethod:nil]; }
- (void)myMethod:(id)sender { /* do things */ }
Upvotes: 12