}方法中的Firebase存储imageReference.delete {(错误),使用“信号SIGABRT”使我的应用崩溃了

时间:2018-07-15 20:30:12

标签: ios swift firebase swift4 firebase-storage

我正在使用:

  • iOS-Swift 4
  • Cocoapods 1.4.0
  • Firebase(5.4.0)
  • FirebaseCore(5.0.5)
  • FirebaseStorage(3.0.0)

当我运行附件代码时,我的应用程序在signal SIGABRT类处崩溃,并出现AppDelegate错误,并在控制台中显示了libc++abi.dylib: terminating with uncaught exception of type NSException

我试图运行一些调试程序,结果发现问题出在imageReference.delete{ (error) in }方法中。

*请注意,它根本没有进入该块,它在方法本身中失败了,因为当我调用{时,该图像不是 not 从Firebase控制台中删除的{1}}方法。

我的代码:

delete

编辑:

经过非常深入的挖掘,我了解到我的问题是我正在“事件树”的某个位置通过闭包调用此方法(我正在调用某个函数,该函数调用另一个函数,而该函数又调用了func deleteImage(for url:String){ print(url) // https://firebasestorage.googleapis.com/v0/b/my-app.appspot.com/o/itemsImages%2F225121501531684886976.jpg?alt=media&token=token let imageReference = Storage.storage().reference(forURL: url) imageReference.delete { (error) in // Fails here with: libc++abi.dylib: terminating with uncaught exception of type NSException print("completion") // Not getting to this point if let error = error{ print(error) } } } 的关闭方法),这就是导致问题的原因。

现在的问题是,如何通过此闭包调用它而不会出现此错误? (我不能在外面叫它)

2 个答案:

答案 0 :(得分:0)

我首先要问您在其他地方是否对该图像有强烈的参考? 还是在UIImage控件中使用了图像?

答案 1 :(得分:0)

最后,问题出在UITableView本身,而不是Firebase。

我没有正确更新UITableView的数据数组,这导致了崩溃。我不知道它是因为xCode控制台中的错误由于某种原因而被禁用(这些答案帮助我将其重新启用:#1#2)。

希望其他任何会遇到有线错误的人(当然,如果没有启用错误日志)将能够利用我的不愉快经验,更快,更轻松地找到解决方案。