以下のソースの処理をループで行っております。画像urlが存在しない場合、
fatal error: unexpectedly found nil while unwrapping an Optional value
となるので、エラー処理を記述したのですがcatchにいきません。
どのように記述したら良いでしょうか。
var hoge: UIImage!
do {
hoge = try UIImage(data: NSData(contentsOfURL: NSURL(string: "http://hoge.com/hoge.png")!)!)!
} catch {
print("error")
}
黄色いメッセージ
No calls to throwing functions occur within 'try' expression
'catch' block is unreachable because no errors are thrown in 'do' block
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/01/14 10:08