Błąd iOS: [__NSArrayI objectAtIndex:]: indeks 1 poza granicami [0 .. 0]

W mojej aplikacji próbuję załadować zawartość z adresu URL, zapisać je w zmiennej tablicy i pokazać w widoku tabeli. Ale nie mogę tego uruchomić, ponieważ przy każdym uruchomieniu aplikacji pojawia się ten błąd:

*** Terminating app due to uncaught exception 'NSRangeException', 
reason: '*** -[__NSArrayI objectAtIndex:]: index 1 beyond bounds [0 .. 0]'
*** First throw call stack:
(0x34dd088f 0x36d9e259 0x34d2823d 0x316e562f 0x315f09a9 0x313c0c5d 0x313c1b95 0x313c1ae7
 0x313c16c3 0xa5cfb 0x33623ec7 0x35387a09 0x35390051 0x33622965 0xa4dc1 0x313a8e33 
 0x313cd629 0x31391d7d 0x314544dd 0x3139a55d 0x3139a579 0x3139a40b 0x3139a3e7 0x313a8015 
 0x313a1985 0x3136fc6b 0x3136f70f 0x3136f0e3 0x3439222b 0x34da4523 0x34da44c5 0x34da3313 
 0x34d264a5 0x34d2636d 0x313a0a13 0x3139de7d 0xa4745 0xa46dc)
terminate called throwing an exception

Tworzę tablicę, która powinna wypełniać tabelę w moim viewDidLoad za pomocą:

_videos = [[NSMutableArray alloc] init];

Następnie łączę się z adresem URL i analizuję otrzymane dane xml. To działa tak, jak powinno. Po otwarciu pewnego tagu tworzę obiekty wideo i po wypełnieniu ich danymi dodaję te obiekty do mojej tablicy za pomocą:

[_videos addObject:currentVideo];

Wydaje się, że to również działa, ponieważ zwraca prawidłową liczbę filmów

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {

    return _videos.count;
}

jest nazywany. Ale po tym punkcie aplikacja ulega awarii i nawet nie osiągam punktu, w którym próbuję zapełnić mój widok tabeli. Funkcja wygląda tak:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    Video *curVideo = [_videos objectAtIndex:indexPath.row];

    static NSString *CellIdentifier = @"CustomCell";

    CustomCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    if (cell == nil)        
        cell = [[CustomCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];

    cell.titleLabel.text = [curVideo title];
    cell.descLabel.text = [curVideo desc];

    return cell;
}

Co robię źle?

Z góry dziękuję

questionAnswers(3)

yourAnswerToTheQuestion