我正在开发一个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