我想打电话给(void)setDoubleValue:(double)value使用performSelectorOnMainThread:.
我认为会起作用的是:
NSNumber *progress = [NSNumber numberWithDouble:50.0];
[progressIndicator performSelectorOnMainThread:@selector(setDoubleValue:)
withObject:progress
waitUntilDone:NO];
Run Code Online (Sandbox Code Playgroud)
没工作.
然后我实现了一个辅助方法:
- (void)updateProgressIndicator:(NSNumber *)progress
{
[progressIndicator setDoubleValue:[progress doubleValue]];
}
Run Code Online (Sandbox Code Playgroud)
工作,但不是很干净.
之后我尝试了NSInvocation.
NSInvocation *setDoubleInvocation;;
SEL selector = @selector(setDoubleValue:);
NSMethodSignature *signature;
signature = [progressIndicator methodSignatureForSelector:selector];
setDoubleInvocation = [NSInvocation invocationWithMethodSignature:signature];
[setDoubleInvocation setSelector:selector];
[setDoubleInvocation setTarget:progressIndicator];
double progress = 50.0;
[setDoubleInvocation setArgument:&progress atIndex:2];
[setDoubleInvocation performSelectorOnMainThread:@selector(invoke)
withObject:nil
waitUntilDone:NO];
Run Code Online (Sandbox Code Playgroud)
这个解决方案有效,但它使用了大量代码并且速度很慢.(即使我存储了调用.)
还有其他方法吗?
我这样做了
[(OfficeLinQViewController*)sharedManager.m_o performSelectorOnMainThread:@selector(findLocalListing::)
withObject:(folderList,path)
waitUntilDone:NO];Run Code Online (Sandbox Code Playgroud)
但问题是在findLocalListing函数中,两个参数路径都保存不了folderList.