CCCallFunc vs CCCallFuncN vs CCCallFuncND

阅读更多

 

这三个东西不一样,前两个容易混淆:它们只差一个字母,参数一模一样
它们存在继承关系:CCCallFunc(父) <-- CCCallFuncN(子) <-- CCCallFuncND(孙)
源码如下:
// CCCallFunc
+(id) actionWithTarget: (id) t selector:(SEL) s
{
	return [[[self alloc] initWithTarget: t selector: s] autorelease];
}

-(void) execute
{
	[targetCallback_ performSelector:selector_];
}

//CCCallFuncN
-(void) execute
{
	[targetCallback_ performSelector:selector_ withObject:target_];
}

//CCCallFuncND
+(id) actionWithTarget:(id)t selector:(SEL)s data:(void*)d
{
	return [[[self alloc] initWithTarget:t selector:s data:d] autorelease];
}
-(void) execute
{
	callbackMethod_(targetCallback_,selector_,target_, data_);
}

你可能感兴趣的:(CCCallFunc vs CCCallFuncN vs CCCallFuncND)