저는 iOS 개발을 처음 접했고 잠시 동안이 버그를 고수했습니다. 나는 웹 서비스를 사용하는 간단한 앱을 만들고있다. 지금 현재 두 개의 뷰 컨트롤러가 있습니다. 로그인보기 컨트롤러 (NIB 파일 포함) 및 기본보기 컨트롤러 (NIB 파일 포함). 응용 프로그램을 만들었을 때 빈 응용 프로그램을 선택 했으므로 스토리 보드가 없습니다. 대신 UINavigationController
을 사용하고 있습니다.UIKeyboardTaskQueue 스레딩 문제
-(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");
}
}];
}
:
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UIKeyboardTaskQueue waitUntilAllTasksAreFinished] may only be called from the main thread.'
이것은 내가 내 제출 버튼이 코드는 : 내 코드를 실행하면 사용자 이름과 비밀번호를 입력하고 로그인보기에 제출 누른 후 다음과 같은 오류가
그리고 여기 내가 지금 갇혀하고 문제가 I 이후 특히 무엇인지 정말 모르겠습니다있어 다음과 같은 기능
[_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];
[email protected]{@"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];
}
코드입니다 키보드로 아무 것도하지 마십시오. 내 블록에 문제가 있다는 느낌이 들지만 문제가 무엇인지 정확히 알지 못합니다. 어떤 도움이라도 대단히 감사하겠습니다.