问题描述
- 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?
解决方案
类本身就是对象,所以只要调用:
[ClassName performSelectorInBackground:@selector(ClassMethod) withObject:nil];
应该就可以
解决方案二:
试试这个;
[ClassName performSelectorInBackground:@selector(methodTobeCalled) withObject:nil];
解决方案三:
用self代替类的名字也可以:
试试
[self performSelectorInBackground:@selector(methodTobeCalled) withObject:nil];
时间: 2025-01-31 01:50:02