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 8597343
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T00:53:32+00:00 2026-06-12T00:53:32+00:00

In my application I try to load contents from a url, store them in

  • 0

In my application I try to load contents from a url, store them in a mutable array and show them in a table view. But I can’t get it working, because every time I run the app this error appears:

*** 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

I create the array that should populate the table in my viewDidLoad with:

_videos = [[NSMutableArray alloc] init];

Then I connect to the url and parse through the received xml data. This works just like it should. When a certain tag is opened I create my video objects and after filling them with data I add those objects to my array with:

[_videos addObject:currentVideo];

This seems to work as well, because it returns the correct number of videos when

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

    return _videos.count;
}

is called. But after this point the app crashes and I don’t even reach the point where I try to populate my table view. The function looks like this:

- (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;
}

What am doing wrong?

Thanks in advance

  • 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-12T00:53:34+00:00Added an answer on June 12, 2026 at 12:53 am

    Somewhere you are likely accessing _videos prior to initializing it. Most likely you’d doing it after init, but prior to loading the view. The fix for this kind of problem is to use accessors exclusively, and to lazy-initialize self.videos. This is one of many reasons never to access your ivars directly except in init and dealloc.

    @interface ...
    @property (nonatomic, readonly, strong) NSMutableArray *videos;
    @end
    
    @implementation ...
    {
      NSMutableArray *_videos; // Can't auto-synthesize. We override the only accessor.
    }
    
    - (NSMutableArray *)videos {
       if (! _videos) {
         _videos = [NSMutableArray new];
       }
       return _videos;
    }
    

    Now all references to self.videos will be initialized no matter when they happen.

    You can also initialize videos correctly in init, which takes a little less code:

    @interface ...
    @property (nonatomic, readonly, strong) NSMutableArray *videos;
    @end
    
    @implementation ...
    
    - (id)init {
       self = [super init];
       if (self) {
         _videos = [NSMutableArray new];
       }
       return self;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Error is something like that : Can't load Items.aspx from 192.168.0.172 And a text
Since installing xcode 4.3 (from the app store), Xcode crashes when I try to
I'm trying to run a sample Java application from the command promopt but I'm
Hii, I'm tring to load swf file to my flash application from a different
I'm trying to use SimplePie with Codeigniter but I can't get even the view
i am trying to load a fxml from a subfolder, but it fails. I
Im working on a small application to try out an idea that I have.
We're re-evaluating our database upgrade process for our application to try and remove the
I am reading properties file in the Dynamic web application as follows : try
I try do develop a web application with ExtJs 4.0. On startup the application

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.