隐式可选仅在iPad Simulator中崩溃。意外发现零

时间:2019-05-10 15:03:23

标签: swift firebase firebase-storage optional

我的应用程序在iphone模拟器中运行良好,但是一旦我将其切换到iPad,它就会崩溃。我使用的是分割视图,主视图是一个表格控制器,可以插入到包含视频和标签的详细视图中。

(让我知道是否需要详细说明我的拆分视图控制器。)

我尝试了两个'String(describing :)'来使该警告静音并提供默认值,但无济于事。

我不确定如何解开这样的东西。

override func viewDidLoad() {
        super.viewDidLoad()
        let videoName =  signs.signName.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)

        //not working in ipad view. crashes. Probably because not every sign has a video yet?
        let httpsReference = Storage.storage().reference(forURL: "https://firebasestorage.googleapis.com/v0/b/lasdictionaryv2.appspot.com/o/\(videoName!).mov") 
        //may need to get rid of force unwrap. because thats not safe. but not sure how.

        httpsReference.downloadURL() { url, error in
            print("URL",url as Any)
            print("ERROR", error as Any)
            if let url = url, error == nil {
                self.videoView.configureForUrl(url)
                self.videoView.isLoop = true
                self.videoView.play()
            }
        }


}

我希望ipad模拟器能够像iphone一样工作。

0 个答案:

没有答案