Ошибка оповещения, заканчивающаяся неперехваченным исключением типа NSException - PullRequest
0 голосов
/ 06 апреля 2020
session.dataTask(with: request) { (data, response, error) in
            if let response = response {
                print(response)
            }
            if let data = data {
                do {
                    //let json = try JSONSerialization.jsonObject(with: data, options: [])
                    let json = try JSONDecoder().decode(ResponseJSON.self, from: data)
                    //print(json)
                    //let successful = json.response.success == 1
                    if json.response.success == 1 {
                        self.xyetki =  true
                        print("xyetki:\(self.xyetki)")
                        self.performSegue(withIdentifier: "toSorumluVC", sender: self)
                    } else {
                        let alert = UIAlertController(title: "Error", message: "Username or Password Incorrect!", preferredStyle: .alert)
                        alert.addAction(UIAlertAction(title: "OK", style: .default, handler: nil))
                        self.present(alert, animated: true, completion: nil)
                    }
                } catch {
                    print(error)
                }
            }
        }.resume()

Соответствующая часть моего кода выше. Я хочу, чтобы он go перешел на другую страницу при входе в систему и отображал сообщение, когда вход в систему невозможен. Выдает ошибку в разделе сообщений. Когда я отлаживаю, в этой строке выдается ошибка «self.present (alert, animated: true, extension: nil)». Буду благодарен за любой прогресс.

libsystem_kernel.dylib`__pthread_kill:
    0x1127b7d38 <+0>:  movl   $0x2000148, %eax          ; imm = 0x2000148 
    0x1127b7d3d <+5>:  movq   %rcx, %r10
    0x1127b7d40 <+8>:  syscall 
->  0x1127b7d42 <+10>: jae    0x1127b7d4c               ; <+20>.   Thread 3: signal SIGABRT
    0x1127b7d44 <+12>: movq   %rax, %rdi
    0x1127b7d47 <+15>: jmp    0x1127b0caf               ; cerror_nocancel
    0x1127b7d4c <+20>: retq   
    0x1127b7d4d <+21>: nop    
    0x1127b7d4e <+22>: nop    
    0x1127b7d4f <+23>: nop   


2020-03-14 21:04:45.354279+0300 Sahadan[9803:496298] *** Assertion failure in -[UIKeyboardTaskQueue waitUntilAllTasksAreFinished], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3698.21.8/Keyboard/UIKeyboardTaskQueue.m:433
2020-03-14 21:04:45.361346+0300 Sahadan[9803:496298] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UIKeyboardTaskQueue waitUntilAllTasksAreFinished] may only be called from the main thread.'
*** First throw call stack:
(
    0   CoreFoundation                      0x000000010def81ab __exceptionPreprocess + 171
    1   libobjc.A.dylib                     0x000000010d046f41 objc_exception_throw + 48
    2   CoreFoundation                      0x000000010defd372 +[NSException raise:format:arguments:] + 98
    3   Foundation                          0x000000010caeb089 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 193
    4   UIKit                               0x000000010f0f6e69 -[UIKeyboardTaskQueue waitUntilAllTasksAreFinished] + 380
    5   UIKit                               0x000000010e671303 -[UIKeyboardImpl setDelegate:force:] + 1596
    6   UIKit                               0x000000010eb5c032 -[UIPeripheralHost(UIKitInternal) _reloadInputViewsForResponder:] + 1054
    7   UIKit                               0x000000010eb65520 -[UIPeripheralHost(UIKitInternal) _preserveInputViewsWithId:animated:reset:] + 498
    8   UIKit                               0x000000010e52a50a -[UIViewController _presentViewController:modalSourceViewController:presentationController:animationController:interactionController:completion:] + 1119
    9   UIKit                               0x000000010e52c297 -[UIViewController _presentViewController:withAnimationController:completion:] + 4621
    10  UIKit                               0x000000010e52edad __63-[UIViewController _presentViewController:animated:completion:]_block_invoke + 99
    11  UIKit                               0x000000010e52f47d -[UIViewController _performCoordinatedPresentOrDismiss:animated:] + 532
    12  UIKit                               0x000000010e52ed0c -[UIViewController _presentViewController:animated:completion:] + 181
    13  UIKit                               0x000000010e52f06b -[UIViewController presentViewController:animated:completion:] + 159
    14  Sahadan                             0x000000010c71adbb _T07Sahadan14ViewControllerC14girisButtonTapyypFy10Foundation4DataVSg_So11URLResponseCSgs5Error_pSgtcfU_ + 2795
    15  Sahadan                             0x000000010c71b0ca _T07Sahadan14ViewControllerC14girisButtonTapyypFy10Foundation4DataVSg_So11URLResponseCSgs5Error_pSgtcfU_TA + 90
    16  Sahadan                             0x000000010c71b657 _T010Foundation4DataVSgSo11URLResponseCSgs5Error_pSgIxxxx_So6NSDataCSgAGSo7NSErrorCSgIyByyy_TR + 263
    17  CFNetwork                           0x00000001116ea738 __75-[__NSURLSessionLocal taskForClass:request:uploadFile:bodyData:completion:]_block_invoke + 19
    18  CFNetwork                           0x00000001116e9f91 __49-[__NSCFLocalSessionTask _task_onqueue_didFinish]_block_invoke + 147
    19  Foundation                          0x000000010ca5d9b7 __NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK__ + 7
    20  Foundation                          0x000000010ca5d81a -[NSBlockOperation main] + 68
    21  Foundation                          0x000000010ca5bcd6 -[__NSOperationInternal _start:] + 778
    22  libdispatch.dylib                   0x000000011232843c _dispatch_client_callout + 8
    23  libdispatch.dylib                   0x000000011232daf4 _dispatch_block_invoke_direct + 592
    24  libdispatch.dylib                   0x000000011232843c _dispatch_client_callout + 8
    25  libdispatch.dylib                   0x000000011232daf4 _dispatch_block_invoke_direct + 592
    26  libdispatch.dylib                   0x000000011232d884 dispatch_block_perform + 109
    27  Foundation                          0x000000010ca57ce4 __NSOQSchedule_f + 342
    28  libdispatch.dylib                   0x000000011232843c _dispatch_client_callout + 8
    29  libdispatch.dylib                   0x000000011232e856 _dispatch_continuation_pop + 967
    30  libdispatch.dylib                   0x000000011232cc86 _dispatch_async_redirect_invoke + 780
    31  libdispatch.dylib                   0x00000001123341f9 _dispatch_root_queue_drain + 772
    32  libdispatch.dylib                   0x0000000112333e97 _dispatch_worker_thread3 + 132
    33  libsystem_pthread.dylib             0x00000001127ec5a2 _pthread_wqthread + 1299
    34  libsystem_pthread.dylib             0x00000001127ec07d start_wqthread + 13
)
libc++abi.dylib: terminating with uncaught exception of type NSException
...