2015-10-17 60 views
-2

爲什麼在更新到iOS 9之後,這行代碼不起作用?iOS 9未聲明的選擇器

的警告未申報的選擇「performThisMethod:_ImageData

上的應用程序崩潰[自performSelector:]

[self performSelector:@selector(performThisMethod:_ImageData:)withObject:nil afterDelay:0.05f]; 

-(void) performThisMethod : (NSData *) data { 
    NSLog(@"Testing this Method"); 

    } 

了什麼蘋果改變?

+2

蘋果沒有任何改變,該代碼可能是從來沒有編譯 – luk2302

回答

0

你的代碼也許應該是

[self performSelector:@selector(performThisMethod:) withObject:_ImageData afterDelay:0.05f]; 

看看this question answers更好地理解performSelector行爲。

+0

偉大的!謝謝。 –

1

您錯誤地使用了performSelector。你想:

[self performSelector:@selector(performThisMethod:) withObject:_ImageData afterDelay:0.05f]; 

更重要的是,使用dispatch_after

dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.05 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ 
    [self performThisMethod:_ImageData]; 
}); 
+0

謝謝! :)派遣工作完美! –

+1

很高興我能幫到你。請不要忘記接受解決您問題的答案。這表明問題已經完成,並增加了您的聲譽。 – rmaddy

相關問題