Browse Source

Fix runtime exception

(cherry picked from commit d5d8dc6f052bcbbcf8e9cd3d03f4cf297e4995b5)
Felix Paul Kühne 9 years ago
parent
commit
992c7f4b0a
1 changed files with 7 additions and 3 deletions
  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];
+        }
     }
 }