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

  • Home
  • SEARCH
  • 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 6981593
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:10:38+00:00 2026-05-27T18:10:38+00:00

My developing iOS application is sometimes terminated after the method addSubview: is called in

  • 0

My developing iOS application is sometimes terminated after the method addSubview: is called in the application delegate (but I’m not sure removeFromSuperview: also involved):

[self.tabBarController.view removeFromSuperview];    
[self.window addSubview:navigationController.view];

What that showed in the log is:

*** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[NSMutableArray objectAtIndex:]: index 0 beyond bounds for empty array'
*** Call stack at first throw:
(
    0   CoreFoundation                      0x019b75a9 __exceptionPreprocess + 185
    1   libobjc.A.dylib                     0x01c41313 objc_exception_throw + 44
    2   CoreFoundation                      0x019ad0a5 -[__NSArrayM objectAtIndex:] + 261
    3   <app_name>                          0x000186dd -[TableViewController tableView:numberOfRowsInSection:] + 205
    4   UIKit                               0x00a742b7 -[UISectionRowData refreshWithSection:tableView:tableViewRowData:] + 1834
    5   UIKit                               0x00a71eb1 -[UITableViewRowData numberOfRowsInSection:] + 110
    6   UIKit                               0x00b60807 -[UISearchDisplayController _updateNoSearchResultsMessageVisiblity] + 115
    7   Foundation                          0x01029669 _nsnote_callback + 145
    8   CoreFoundation                      0x0198f9f9 __CFXNotificationPost_old + 745
    9   CoreFoundation                      0x0190e93a _CFXNotificationPostNotification + 186
    10  Foundation                          0x0101f20e -[NSNotificationCenter postNotificationName:object:userInfo:] + 134
    11  UIKit                               0x008df649 -[UIWindow _setRotatableClient:toOrientation:updateStatusBar:duration:force:] + 4581
    12  UIKit                               0x008d9254 -[UIWindow _setRotatableViewOrientation:duration:force:] + 89
    13  UIKit                               0x008db38f -[UIWindow setAutorotates:forceUpdateInterfaceOrientation:] + 794
    14  UIKit                               0x008d9081 -[UIWindow setDelegate:] + 252
    15  UIKit                               0x00964dee -[UIViewController _tryBecomeRootViewControllerInWindow:] + 106
    16  UIKit                               0x00975340 -[UINavigationController viewDidMoveToWindow:shouldAppearOrDisappear:] + 72
    17  UIKit                               0x008f0e4b -[UIView(Internal) _didMoveFromWindow:toWindow:] + 918
    18  UIKit                               0x008efa60 -[UIView(Hierarchy) _postMovedFromSuperview:] + 166
    19  UIKit                               0x008e8750 -[UIView(Internal) _addSubview:positioned:relativeTo:] + 1080
    20  UIKit                               0x008e6aa3 -[UIView(Hierarchy) addSubview:] + 57
    21  <app_name>                          0x00004971 -[AppDelegate requestFinished:] + 993
    22  <app_name>                          0x0003e65b -[ASIHTTPRequest reportFinished] + 171
    23  Foundation                          0x0103e94e __NSThreadPerformPerform + 251
    24  CoreFoundation                      0x019988ff __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
    25  CoreFoundation                      0x018f688b __CFRunLoopDoSources0 + 571
    26  CoreFoundation                      0x018f5d86 __CFRunLoopRun + 470
    27  CoreFoundation                      0x018f5840 CFRunLoopRunSpecific + 208
    28  CoreFoundation                      0x018f5761 CFRunLoopRunInMode + 97
    29  GraphicsServices                    0x01db11c4 GSEventRunModal + 217
    30  GraphicsServices                    0x01db1289 GSEventRun + 115
    31  UIKit                               0x008c5c93 UIApplicationMain + 1160
    32  <app_name>                          0x00002a30 main + 192
    33  <app_name>                          0x00002255 start + 53
)
terminate called throwing an exception

How can I find out the reason why the app is terminated by this log and solve it? Thank you.

Note: Edit 1 and Edit 2 were removed.

Edit 3: This implemented code of tableView:numberOfRowsInSection: method works for me:

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (tableView == self.searchDisplayController.searchResultsTableView)
    {
        if (filteredSectionListOfAddressBook && filteredSectionListOfAddressBook.count)
        {
            return [[filteredSectionListOfAddressBook objectAtIndex:section] count];
        }
        else
        {
            return 0;
        }
    }
    else if (tableView == self.tableView)
    {
        if (sectionListOfAddressBook && sectionListOfAddressBook.count)
        {
            return [[sectionListOfAddressBook objectAtIndex:section] count];
        }
        else
        {
            return 0;
        }
    }

    return 0;
}
  • 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-05-27T18:10:38+00:00Added an answer on May 27, 2026 at 6:10 pm

    In your stack trace – there is a tableview – you need to ensure that there is data to populate the table. Thats where this error is coming from

    *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[NSMutableArray objectAtIndex:]: index 0 beyond bounds for empty array
    

    You could for the moment ensure there is no data by making sure that

    tableView:numberOfRowsInSection: returns 0;

    Have you implemented the TableViews delegate methods?

    Read about it here About Table Views in iOS-Based Applications

    here UITableViewDataSource Protocol Reference

    and here UITableViewDelegate Protocol Reference

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

Sidebar

Related Questions

I'm developing web-application (and also native iOS app) that uses images from different websites.
I am developing an iOS application, and trying to zip the file I have
When developing a desktop application in .NET, is it possible to not require the
I'm developing an iOS 4 with latest SDK and XCode 4.2 (I'm not using
I'm developing a large scale application for iOS 5 using ARC in xcode. The
I am developing a PhoneGap application for Android (will work on iOS too). The
When developing on BlackBerry or iOS, you can deploy your application just by dropping
I'm developing an iOS application that will be used just by a company employees
I'm developing an iOS 4 application. I have a ViewController that contains another class.
I developing a Google Maps application for iOS. I have a problem. I sent

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.