Steve N
Steve N

Reputation: 2737

performSelector:withObject:afterDelay from class method not working

Any idea why this isn't working?

[self performSelector:@selector(foo:) withObject:argObj afterDelay:5.0];

I am calling this from within a class method, and it is calling another class method for the same class (hence 'self'). Is this valid?

I placed a breakpoint in foo, but it is not called. What's going on here?

Upvotes: 6

Views: 3586

Answers (3)

bbum
bbum

Reputation: 162712

Do you have a run loop running on the thread from which you invoke the perform:afterDelay:? If not, it won't run.

Upvotes: 7

AechoLiu
AechoLiu

Reputation: 18368

- (void)performSelector:(SEL)aSelector withObject:(id)anArgument afterDelay:(NSTimeInterval)delay

The method is an instance method, the receiver should be an instance of class. It needs a concrete object to perform the action. So I don't think it will work in class method.

Upvotes: -1

Craig Otis
Craig Otis

Reputation: 32054

Maybe I'm misunderstanding your question, but why are you using the self keyword in a static context in the first place? Why not simply change self to the name of the class?

Upvotes: -1

Related Questions