我收到了神秘的崩溃报告,而对于我的生活,我无法弄清楚可能导致此错误的原因。但是,我不是一个熟练的iOS / Swift开发人员,所以对其他人来说可能很明显!
这是堆栈:
function signature specialization <Arg[1] = Value Promoted from Box> of closure #1 () -> () in Company.LoginViewController.(logIn in _10D245F74F8D2701C8F7339313EB1733)() -> ()
LoginViewController.swift - line 275
SIGABRT
libsystem_kernel.dylib
__pthread_kill
libsystem_c.dylib
abort
libswiftCore.dylib
0x103964000 + 2666636
libswiftCore.dylib
0x103964000 + 2666896
libswiftCore.dylib
0x103964000 + 2869624
Company
function signature specialization <Arg[1] = Value Promoted from Box> of closure #1 () -> () in Company.LoginViewController.(logIn in _10D245F74F8D2701C8F7339313EB1733)() -> () LoginViewController.swift:275
Company
_T0Ieg_IeyB_TR LoginViewController.swift:0
Company
_T0So8NSStringCIeyBy_SSIegx_TRTA AuthenticationManager.swift:0
Company
function signature specialization <Arg[0] = Owned To Guaranteed> of closure #1 (__ObjC.AFOAuthCredential) -> () in Company.AuthenticationManager.authenticate(with: Swift.String, password: Swift.String, success: (Swift.String) -> (), failure: (__ObjC.INTAuthenticationError) -> ()) -> () AuthenticationManager.swift:105
以下是相关功能:
private func logIn() {
beginAuthentication()
let credentials = INTUserCredentials()
credentials.username = email.text
credentials.password = password.text
authenticationModel.logIn(with: credentials, success: { [unowned self] in
// *** Crashes here, oddly on an empty line ***
let finish = { [weak self] in
self?.endAuthentication()
if let delegate = self?.delegate {
delegate.authenticationViewControllerDidLogin(self?.registrationInfoContainer)
}
}
}, failure: { [weak self] errorMessage in
self?.showErrorMessage(errorMessage)
})
}
答案 0 :(得分:1)
您引用为self(LoginViewController?)的对象是否可能被丢弃?我可以想象,您的authenticationModel-class的函数logIn的签名需要非可选属性。但是,在调用logIn()函数之后,对象不再被使用并被释放(因为[unowned self])...只需在dealloc函数中放置一个断点,看看会发生什么。顺便说一句,dealloc函数不应为空以使断点停止