我正在開發一個iPhone應用程序,我試圖在某些延遲後調用特定的方法。但該方法沒有被調用。我不知道爲什麼它沒有被調用。self performSelector:withObject:afterDelay:不調用方法
這裏是我的代碼
-(void)gettingCommentsList { // some stuff....
[self performSelector:@selector(callGetListInBackgroundMethod) withObject:nil afterDelay:1.0]; }
-(void)callGetListInBackgroundMethod {
isFromthread =YES;
NSLog(@"callGetListInBackground");
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
// Add code here to do background processing
//
//
[self gettingCommentsList];
dispatch_async(dispatch_get_main_queue(), ^{
// Add code here to update the UI/send notifications based on the
// results of the background processing
[self.commentsTbl reloadData];
});
});
}
感謝
按住Alt鍵並將鼠標懸停在方法上以檢查方法是否被識別。否則調用像'[self performSelector:@selector(callGetListInBackgroundMethod :) withObject:nil afterDelay:0.4];' – user1673099
你確定'performSelector:withObject:afterDelay:'實際上被調用? – sergio
是的,我確定它叫做 – user2185354