我注册了duc tran的SYA 2,并在newsfeed应用程序中收到此错误:
fatal error: unexpectedly found nil while unwrapping an Optional value
尝试访问评论时会发生这种情况。有任何想法吗?
最佳答案
这里的注释不是可选值,因此我们应该检查并设置数据。
用替换comments = media.comments
if let comments = media.comments {
self.comments = comments
}
or
如下进行可选注释,
let comments: [Comment]? = [Comment]()
同样,在您的情况下,
comments
类的Media
属性也应该是可选的。当您从非可选属性读取数据时,该属性不应为nil。
关于swift - fatal error : unexpectedly found nil while unwrapping an Optional value - Duc Tran,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40815509/