我想从服务器URL提取图像到我的条形按钮项中。我正在使用如下代码,但它给出了一个错误:线程1:致命错误:意外地发现nil,同时隐式展开了Optional值。我怎么解决这个问题 ?注意:loadImg func是扩展,它在另一个控制器上工作。 serverURL是我的个人资料数据类。
dl[i].LatestRevision.Date.Ticks, //This is the problem child - apparently calling .LatestRevision
//causes massive overhead, the other two
//DateTimes are no problem at all, loop executes in
//under 1/10th of a second.
答案 0 :(得分:0)
您将强制展开两个可选选项(标记为import Data.Char (isDigit)
import Data.List (span)
>>> span (not . isDigit) "ab2de4"
("ab","2de4")
)。如果它们中的一个或两个都不为零,则会崩溃。因此,您需要先检查它们是否存在,否则请保释。
类似这样的东西:
!