切换视图时的Segue问题

时间:2017-04-18 14:20:43

标签: ios segue

当我执行通过单击图像视图执行的另一个视图的segue时,我当前在我的应用程序上收到错误。

错误说明:致命错误:在展开可选值时意外发现nil。我不确定为什么会这样,但下面是error正在发生的图像。我假设segue有问题,因为单击按钮时会发生错误。但是这段代码突出显示错误让我感到困惑?

这是代码:

func loadComments() {

    let postCommentRef = FIRDatabase.database().reference().child("post-comments").child(self.postId)

    postCommentRef.observe(.childAdded, with: {
        snapshot in
        print("observe key")
        print(snapshot.key)
        FIRDatabase.database().reference().child("comments").child(snapshot.key).observeSingleEvent(of: .value, with: {
            snapshotComment in

            if let dict = snapshot.value as? [String: Any] {

                //Retrieving from the database - post Model created class

                let newComment = Comment.transformComment(dict: dict)

                self.getUser(uid: newComment.uid!, completed: {

                    self.comments.append(newComment)
                    self.tableView.reloadData()


                })

            }
        })
    })

}

0 个答案:

没有答案