Ios UIKeyboardTaskQueue线程问题

Ios UIKeyboardTaskQueue线程问题,ios,objective-c,multithreading,objective-c-blocks,Ios,Objective C,Multithreading,Objective C Blocks,我对iOS开发相当陌生,我已经被这个bug困扰了一段时间。我正在制作一个使用web服务的简单应用程序。现在我有两个视图控制器。一个登录视图控制器(带其NIB文件)和一个主视图控制器(带其NIB文件)。当我创建应用程序时,我选择了一个空的应用程序,所以我没有故事板。相反,我使用的是UINavigationController。当我运行代码时,在登录视图中输入用户名和密码并按submit键后,会出现以下错误: 由于未捕获的异常“nsinternalinconsistenceexception”而终止

我对iOS开发相当陌生,我已经被这个bug困扰了一段时间。我正在制作一个使用web服务的简单应用程序。现在我有两个视图控制器。一个登录视图控制器(带其NIB文件)和一个主视图控制器(带其NIB文件)。当我创建应用程序时,我选择了一个空的应用程序,所以我没有故事板。相反,我使用的是
UINavigationController
。当我运行代码时,在登录视图中输入用户名和密码并按submit键后,会出现以下错误:

由于未捕获的异常“nsinternalinconsistenceexception”而终止应用程序,原因:'-[UIKeyboardTaskQueue WaitUntillallTasksRefiefined]只能从主线程调用。

这是我提交按钮的代码:

-(IBAction)logIn:(id)sender{
    UIApplication *application = [UIApplication sharedApplication];
    application.networkActivityIndicatorVisible = YES;

    [_loginNetworkingContorller checkCredentialsWithUsername:self.username.text withPassword:self.password.text completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
        if(!error){
            NSHTTPURLResponse *httpResp = (NSHTTPURLResponse*) response;
            if (httpResp.statusCode == 200) {
                NSLog(@"SUCESS");
                NSDictionary *credentials = @{self.username.text: self.password.text};
                [KeychainUserPass save:@"MY APP" data:credentials];
                UIViewController *mainView = [[RDMainViewController alloc] initWithNibName:@"RDMainViewController" bundle:nil];

                [self.navigationController pushViewController:mainView animated:YES];
            }
            else{
                NSLog(@"ERROR");
            }
        }
        else{
            NSLog(@"ERROR");
        }
    }];
}
下面是下面函数的代码

[_loginNetworkingContorller checkCredentialsWithUsername:self.username.text withPassword:self.password.text completionHandler:^(NSData *data, NSURLResponse *response, NSError *error)

-(void)checkCredentialsWithUsername:(NSString *)username withPassword:(NSString *)password completionHandler:(void (^)(NSData *data,NSURLResponse *response, NSError *error))myCompletion
{
    NSString *requestString = @"SOME WEBSITE";
    NSURL *url = [NSURL URLWithString:requestString];
    NSURLRequest *req = [NSURLRequest requestWithURL:url];

    NSData *userPasswordData = [[NSString stringWithFormat:@"%@:%@", username, password] dataUsingEncoding:NSUTF8StringEncoding];
    NSString *base64EncodedCredential = [userPasswordData base64EncodedStringWithOptions:0];
    NSString *authString = [NSString stringWithFormat:@"Basic %@", base64EncodedCredential];

    NSURLSessionConfiguration *sessionConfig=[NSURLSessionConfiguration defaultSessionConfiguration];
    sessionConfig.HTTPAdditionalHeaders=@{@"Authorization":authString};

    self.session=[NSURLSession sessionWithConfiguration:sessionConfig];

    NSURLSessionDataTask *dataTask = [self.session dataTaskWithRequest:req completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
        myCompletion(data, response, error);
    }];

    [dataTask resume];
}

我现在陷入困境,不确定问题出在哪里,尤其是因为我对键盘什么都不做。我感觉我的积木有问题,但我不确定问题出在哪里。任何帮助都将不胜感激

嘿,我接到网络电话的回复后也遇到了同样的问题。我通过以下方法解决了这个问题:

 //do something with response

  dispatch_async(dispatch_get_main_queue()) { () -> Void in

     // continue with program by calling next step on main thread           
  }
我认为如果你推到下一个视图控制器,iOS会尝试在非主线程上进行操作,从而导致错误,但我不是100%认为这是正确的