Tag: performselector

iOS具有多个参数的performSelectorOnMainThread

我想在另一个线程的主线程上执行select器,但select器有多个参数,类似于: -(void) doSomethingWith:(int) ab:(float)bc:(float)cd:(float)de:(float)e { //… } 我怎么能得到这个performSelectorOnMainThread: withObject: waitUntilDone: 编辑 我想解释为什么我需要这个。 我在主线程上使用UIImageViews,并在另一个线程上对它们进行计算。 我使用了大量的计算,所以如果我在主线程上做了所有的事情,应用程序就会滞后。 我知道UI元素只能在主线程中操作,这就是为什么我想这样工作,所以主线程可以听触摸事件没有滞后。

子类化NSOperation是并发的和可取消的

我无法find有关如何将NSOperation子类NSOperation并发的良好文档,也支持取消。 我读了苹果文档,但是我找不到一个“官方”的例子。 这是我的源代码: @synthesize isExecuting = _isExecuting; @synthesize isFinished = _isFinished; @synthesize isCancelled = _isCancelled; – (BOOL)isConcurrent { return YES; } – (void)start { /* WHY SHOULD I PUT THIS ? if (![NSThread isMainThread]) { [self performSelectorOnMainThread:@selector(start) withObject:nil waitUntilDone:NO]; return; } */ [self willChangeValueForKey:@"isExecuting"]; _isExecuting = YES; [self didChangeValueForKey:@"isExecuting"]; if (_isCancelled == YES) { NSLog(@"** […]

如何实现与多个参数和afterDelay performSelector?

我是一个iOS新手。 我有一个select器方法如下 – – (void) fooFirstInput:(NSString*) first secondInput:(NSString*) second { } 我正在尝试执行这样的事情 – [self performSelector:@selector(fooFirstInput:secondInput:) withObject:@"first" withObject:@"second" afterDelay:15.0]; 但是那给了我一个错误 – Instance method -performSelector:withObject:withObject:afterDelay: not found 任何想法,我所缺less的?