2016-12-01 2 views

答えて

2

item[file]nilであり、あなたがアンラップ力を利用しているため、この

for item in files { 
    // this line gets marked, but why this line? 
    if let file = item["file"] as String { 
     print("file ", file) 
     self.download(remoteBaseUrl.URLByAppendingPathComponent(file) 
    } else { 
     print("file not available") 
    } 

} 
+1

'!' force unwrap opereratorを "nilのクラッシュ"演算子と考えてください。それはそれがするものです。アンラッピングしているものが決してゼロにならないことを100%確信していない場合は、使用しないでください。 –

+0

私の理論では決して無限になることはありませんでしたが、これは参照を作成します: 'self.filesToDownload = files'と私はダウンロードしたところでアイテムを取り除き、' NSMutableArray 'に穴ができないので、 'nil'。私の新しい理論です:)しかし、もっとそれをテストする必要があります。 – mnewmedia