2 ooomiao oOOMIAO 于 2012.11.28 14:10 提问

objective中在背景调用类方法

在下面这段摘录代码中:

/*A ClassName with instanceMethod and ClassMethod  */

-(void)instanceMethod;

+(void)ClassMethod;

/*To call a instance method in background */

ClassName  class1obj = [ClassName alloc] init];

[class1obj performSelectorInBackground:@selector(instanceMethod) withObject:nil];

怎么用performSelectorInBackground在背景中调用ClassMethod?

3个回答

gaoXxxing
gaoXxxing   2012.11.28 14:37
已采纳

类本身就是对象,所以只要调用:

[ClassName performSelectorInBackground:@selector(ClassMethod) withObject:nil];

应该就可以

oOOMIAO
oOOMIAO 谢谢
大约 5 年之前 回复
Mr_me
Mr_me   2012.11.28 14:44

试试这个;

[ClassName performSelectorInBackground:@selector(methodTobeCalled) withObject:nil];
lanhailvcao
lanhailvcao   2012.11.28 14:48

用self代替类的名字也可以:
试试

[self performSelectorInBackground:@selector(methodTobeCalled) withObject:nil];
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!