Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8232625
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T17:53:45+00:00 2026-06-07T17:53:45+00:00

I have a UITableView for an app I am creating that will show Movie

  • 0

I have a UITableView for an app I am creating that will show Movie Trailers.

In my RootViewController.h file I have this code (well all of the relevant code needed is supplied here):

@interface RootViewController : UITableViewController {
    NSMutableArray *listOfLinks;
}

In my .m is this code:

- (void)viewDidLoad {
    [super viewDidLoad];
    listOfLinks = [[NSMutableArray alloc] init];
    NSURL *myurl2 = [NSURL URLWithString:@"http://website.com/movietrailers.plist"];
    NSDictionary *plistDict2 = [NSDictionary dictionaryWithContentsOfURL:myurl2];
    NSArray *plistArray2 = [plistDict2 objectForKey:@"MovieLinks"];
    NSDictionary *dic = [NSDictionary dictionaryWithObject:plistArray2 forKey:@"MovieLinks"];
    [listOfLinks addObject:dic];
    NSLog(@"%@", listOfLinks);
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    NSURL *movieURL = [listOfLinks objectAtIndex:indexPath.row];
    MPMoviePlayerViewController *moviePlayer = [[MPMoviePlayerViewController alloc] initWithContentURL:movieURL];
    [self presentMoviePlayerViewControllerAnimated:moviePlayer];
    [moviePlayer release];
}

My plist looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>MovieTitles</key>
    <array>
        <string>Movie 1</string>
        <string>Movie 2</string>
    </array>
    <key>MovieLinks</key>
    <array>
        <string>http://trailerserver.com/movie1.mp4</string>
        <string>http://trailerserver.com/movie2.mp4</string>
    </array>
</dict>
</plist>

But I am essentially getting the error that listOfLinks is empty. The error looks like this:

Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 6 beyond bounds [0 .. 0]'

When I NSLog the array it prints out it’s strings. What is the reason for this? Thanks for your help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T17:53:46+00:00Added an answer on June 7, 2026 at 5:53 pm

    You added 1 dictionary to an array and are now trying to get the 6th item, you only have one. When you log it, you see the contents of the single dictionary you have there.

    When you are doing the numberOfRowsInSection you are probably returning the count of the dictionary, not the array, and I am guessing you want the dictionary, so you should have

    NSDictionary* d = [listOfLinks objectAtIndex:0];
    NSURL *movieURL = [[listOfLinks [d allKeys]] objectAtIndex: indexPath.row];
    MPMoviePlayerViewController *moviePlayer = [[MPMoviePlayerViewController alloc] initWithContentURL:movieURL]
    

    or something along those lines

    EDIT for your updated question.

    I am not sure why you are storing the info in a dictionary. In fact you are getting an array of elements from a dictionary, then creating a dictionary with it and putting it in an array. That makes no sense.

    In your part of the code where you go:

    NSDictionary *plistDict2 = [NSDictionary dictionaryWithContentsOfURL:myurl2];
    NSArray *plistArray2 = [plistDict2 objectForKey:@"MovieLinks"];
    

    this would appear you have an array at that moment, so why do you do this:

    NSDictionary *dic = [NSDictionary dictionaryWithObject:plistArray2 forKey:@"MovieLinks"];
    [listOfLinks addObject:dic];
    

    which creates a dictionary and puts the dictionary in element 0 of an array?

    If you want listOfLinks to contain a list of links that you get from the MovieLinks key, why not put them straight into the array?

    if(plistArray2 != nil && [plistArray2 count] > 0)
        [listOfLinks addObjectsFromArray:plistArray2];
    

    then in your accessors:

    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
    {
        if(section == WHATEVERSECTION)
            return [listOfLinks count];
        return 0;
    }
    
    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
    {
        NSURL *movieURL = [listOfLinks objectAtIndex:indexPath.row];
        MPMoviePlayerViewController *moviePlayer = [[MPMoviePlayerViewController alloc] initWithContentURL:movieURL];
        [self presentMoviePlayerViewControllerAnimated:moviePlayer];
        [moviePlayer release];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating an App with following design: I have a UITableView with custom
I have an app that uses a UITableView to list documents which are stored
I have an iOS app with a UITableView that has flexible width, which allow
In my iPhone app I have a UIViewController that has a UITableView and another
I have this UITableView app, a basic diary app, in this method XCode says
In my app I have a UITableView that contains custom UITableViewCells. Scrolling is very
In my app, I have a UITableView that is populated by Core Data, currently
Let's say I have a UITableView that is part of an iPad app doesn't
Hey everyone, I have a iPhone App I am creating. It uses a uitableview
In the app that io am creating, i have a custom copy of UISplitView

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.