How can I use [self performSelector: withObject: afterDelay:] method in +(void)classMethod?
I’ve got a sprite defined in the following:
+(void)classMethod
{
CCSprite * sprite = [CCSprite spriteWithFile:@"sprite.png"];
//and hope afterDelay3.0second remove this sprite
[self performSelector:@select(clean:) withObject:sprite afterDelay:3.0];
}
+(void)clean:(CCSprite *)sprite
{
[sprite removeFromSuperView];
}
Technically
selfrefers to theObjectof given class, In your case you are not creating anObjectso you won’t be able to callObjectmethods from static method.Visual
A quick test shows that, If you method is declared instance level then you will not be able to access it from your class method.
In your case,
is a class method but,
is an instance method of
NSObject, That is why you are not able to call from your class method.Apple Doc,
That means you are accessing instance method from class method, which is not allowed.