瀏覽代碼

Fix runtime exception

(cherry picked from commit d5d8dc6f052bcbbcf8e9cd3d03f4cf297e4995b5)
Felix Paul Kühne 9 年之前
父節點
當前提交
992c7f4b0a
共有 1 個文件被更改,包括 7 次插入3 次删除
  1. 7 3
      Apple-TV/VLCServerBrowsingTVViewController.m

+ 7 - 3
Apple-TV/VLCServerBrowsingTVViewController.m

@@ -128,10 +128,14 @@
 
 - (void)collectionView:(UICollectionView *)collectionView willDisplayCell:(UICollectionViewCell *)cell forItemAtIndexPath:(NSIndexPath *)indexPath
 {
-    id<VLCNetworkServerBrowserItem> item = self.serverBrowser.items[indexPath.row];
+    NSArray *items = self.serverBrowser.items;
+    NSInteger row = indexPath.row;
+    if (row < items.count) {
+        id<VLCNetworkServerBrowserItem> item = items[row];
 
-    if ([cell conformsToProtocol:@protocol(VLCRemoteBrowsingCell)]) {
-        [self.browsingController configureCell:(id<VLCRemoteBrowsingCell>)cell withItem:item];
+        if ([cell conformsToProtocol:@protocol(VLCRemoteBrowsingCell)]) {
+            [self.browsingController configureCell:(id<VLCRemoteBrowsingCell>)cell withItem:item];
+        }
     }
 }