我使用NSData
將UIImage
從光盤庫轉換爲NSData
,但它給。UIImage到NSData致命錯誤:意外地發現零,而解包一個可選值
error fatal error: unexpectedly found nil while unwrapping an Optional value
以下是我的代碼
if(o.count == 1)
{//o is [UIImage]
let imgdata:NSData? = UIImageJPEGRepresentation(self.o[0], 10)
print(o[0]) //it show <UIImage: 0x14e123cb0>, {30, 40}
print(imgdata)
}
如果打印顯示一個UIImage(而不是零),那麼錯誤是在別的地方 –