简体   繁体   English

在完成处理程序中执行选择器不起作用?

[英]perform selector inside completion handler not working?

    [[FHSTwitterEngine sharedEngine]showOAuthLoginControllerFromViewController:self withCompletion:^(BOOL success) {

        if(success){

            [self performSelector:@selector(goToHome:) withObject:@"twitter"];
        }
    }];

In goToHome method i'm simply sending user to other screen after saving some data. 在goToHome方法中,我只是在保存一些数据后将用户发送到其他屏幕。 but goToHome method doesn't get call from completion handler. 但是goToHome方法不会从完成处理程序中获取调用。

Try this 尝试这个

[[FHSTwitterEngine sharedEngine]showOAuthLoginControllerFromViewController:self withCompletion:^(BOOL success) {

    if(success){
        dispatch_async(dispatch_get_main_queue(), ^{
            [self performSelector:@selector(goToHome:) withObject:@"twitter"];
        });
    }
}];

If you Don't have any object to pass then just pass nil and if you have any object to pass this goToHome method pass that object. 如果您没有要传递的任何对象,则只需传递nil,如果您有任何要传递的goToHome方法,请传递该对象。 Right now you are passing a string not the object, If you need pass an object of string type then it should work fine or else there is an issue. 现在,您传递的是字符串而不是对象,如果您需要传递字符串类型的对象,则它应该可以正常工作,否则会出现问题。

So pass the required object or just nil and it will be working. 因此,传递所需的对象或将其传递为nil即可。

You can even try this out : 您甚至可以尝试一下:

[self performSelectorOnMainThread:@selector(goToHome:) @"twitter" waitUntilDone:YES]; [self performSelectorOnMainThread:@selector(goToHome :) @“ twitter” waitUntilDone:YES];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM