我正在使用Alamofire库进行网络通话 每当我尝试在请求中实现与UI相关的任何内容时,它都会崩溃 例如,当我想显示对话框时,它会崩溃
Alamofire.request(url, method: .post, parameters: parameters).responseString { response in
switch response.result {
case .success:
print("Validation Successful")
case .failure(let error):
print(error)
}
print("Success: \(response.result.isSuccess)")
print("Response String: \(String(describing: response.result.value) )")
if let data = response.data, let utf8Text = String(data: data, encoding: .utf8) {
print("Data: \(utf8Text)")
}
self.showCallBackDialog()
}
如果我删除showCallBackDialog它工作正常,我保证showCallBackDialog工作正常,当我在Alamofire请求之外使用它时它可以工作
错误消息:
2017-10-12 00:15:55.889747+0530 MagicHands[43034:8535265] *** Assertion failure in -[UIApplication _cachedSystemAnimationFenceCreatingIfNecessary:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3694.4.18/UIApplication.m:1706
2017-10-12 00:15:55.905170+0530 MagicHands[43034:8535265] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'accessing _cachedSystemAnimationFence requires the main thread'
*** First throw call stack: