Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 对所有对象执行cancelPreviousPerformRequestsWithTarget:selector:object:_Objective C_Cocoa_Cocoa Touch_Grand Central Dispatch - Fatal编程技术网

Objective c 对所有对象执行cancelPreviousPerformRequestsWithTarget:selector:object:

Objective c 对所有对象执行cancelPreviousPerformRequestsWithTarget:selector:object:,objective-c,cocoa,cocoa-touch,grand-central-dispatch,Objective C,Cocoa,Cocoa Touch,Grand Central Dispatch,我正在为不同的对象安排不同的选择器 [self performSelector:@selector(doSmth) withObject:objectA afterDelay:1]; [self performSelector:@selector(doSmth) withObject:objectB afterDelay:1]; [self performSelector:@selector(doSmthElse) withObject:objectA afterDelay:1]; 我想取消所

我正在为不同的对象安排不同的选择器

[self performSelector:@selector(doSmth) withObject:objectA afterDelay:1];
[self performSelector:@selector(doSmth) withObject:objectB afterDelay:1];
[self performSelector:@selector(doSmthElse) withObject:objectA afterDelay:1];
我想取消所有的'doSmth',如何做?而不知道传递的对象

这将取消一切

[NSObject cancelPreviousPerformRequestsWithTarget:self];
这不会取消任何内容(因为对象不匹配)


即使是我也会排除行为(如果传递了nil,则对任何对象取消,但这不会发生)

无法获取挂起的
performSelector
请求列表,因此您需要维护传递给
performSelector
的参数列表,以便以后可以取消它们

[NSObject cancelPreviousPerformRequestsWithTarget:object 
    selector:@selector(doSmth) object:nil];