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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:27:21+00:00 2026-06-15T17:27:21+00:00

I have subclassed an UITableViewController , which I am instantiating trough a segue. It

  • 0

I have subclassed an UITableViewController, which I am instantiating trough a segue.

It seems that the table view controller is correctly instantiated as viewDidLoad and numberOfSectionsInTableView are being called.
In fact, numberOfSectionsInTableView is called even twice. When it is called first, it has a valid value for tableView, when it is called for the second time (right after the first call), tableView is nil.

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return [super numberOfSectionsInTableView:tableView] + 1 ;
}

I am using a static cell (in section 0, row 0) which I have set up in Interface Builder and I am adding a dynamic number of rows in the second section (section 1). That is why I have added 1 to [super numberOfSectionsInTableView:tableView]. There is no custom code in the parent’s tableView class, everything is just set up in Interface Builder.

All outlets seem to be set correctly:

enter image description here

When the execution of the code continues, the app crashes with the error message:

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

Do you have any idea on what could cause the error?

  • 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-15T17:27:21+00:00Added an answer on June 15, 2026 at 5:27 pm
    - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
        return [super numberOfSectionsInTableView:tableView] + 1 ;
    }
    

    Basically means that every time numberOfSectionsInTableView gets called the number of sections in the table will increase by 1. That being said, if you are only ever going to have two sections in the table, you’d be better off with return 2;.

    Now, on to your error. It’s kind of hard to say considering I don’t know the exact context or where the error occurred, but my first guess is that the crash happened in cellForRowAtIndexPath because your datasource is either nil or and is an empty array.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an UITableViewController to manage an table view which created with subclassed prototype
I've got a UITableViewController which has a table view with custom cells (they have
I have a custom UITableViewCell subclass, and a table view controller which I want
I have a view that contains a UITableView and a UILabel which works perfectly
I have a table view that displays custom cells, the cells contain an image
I have a subclass of UITableViewController. I have code that can add/remove a UISearchBar
I have created a subclass of UITableViewController that is used as the custom class
I have subclassed UIView object inside a uiscrollview which displays a pdf page. I
I have a problem where I can successfully push a new view controller from
I have a view based app that works well. (In other words, I'm not

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.