views:

195

answers:

2

Do you only postfix the method name with a : if you are calling a foreign object?

For some reason

[self performSelector:@selector(myMethod:) withObject:nil afterDelay:5];

Does not work but

[self performSelector:@selector(myMethod) withObject:nil afterDelay:5];

Does!

EDIT:

Declared in the implementation of a class but not the interface.

- (void)myMethod
{
   // Some stuff
}
+3  A: 

In Objective-C the colons are part of the method name. That is, myMethod and myMethod: are distinct selectors (and in your case, only the latter exists).

For instance, for a method declared like:

-(void)doSomethingWithFoo:(int)foo andBar:(int)bar;

The selector is doSomethingWithFoo:andBar:.

dcrosta
actually, in his case, only the former exists.
mmc
+8  A: 

The colon represents a method argument. Since myMethod takes no arguments its selector can't have a colon. If you had multiple arguments like this...

- (void)myMethod:(id)method object:(id)object enabled:(BOOL)bool {
  // Some Stuff
}

... the selector would be @selector(myMethod:object:enabled:)

probablyCorey