我正在開發一個iOS應用程序,它從照片庫中獲取視頻,並且它一直工作。我只是測試的應用程序在不同的設備上(這是不是我考第一),它崩潰,當我使用檢索到的數據,我不明白爲什麼...NSRangeException與PHFetchResult
這裏是我的代碼:
self.videosAssets = PHAsset.fetchAssetsWithMediaType(.Video, options: nil)
if self.videosAssets != nil {
for i in 0..<self.videosAssets!.count {
if let video = self.videosAssets!.objectAtIndex(i) as? PHAsset {
self.videos.append(Video(asset: video))
}
}
}
它獲取221個視頻,但它崩潰時,我== 59
以下是錯誤我得到:
Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArray0 objectAtIndex:]: index 0 beyond bounds for empty NSArray'
不,它不會在'我== 59',它崩潰索引0崩潰,你肯定是代碼實際上導致錯誤/崩潰? – luk2302
我意識到之後,我沒有測試視頻構造函數......我認爲應用程序崩潰在這裏。我將在星期一進行測試 –