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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:28:06+00:00 2026-05-23T08:28:06+00:00

I have this error in xcode: Terminating app due to uncaught exception ‘NSRangeException’, reason:

  • 0

I have this error in xcode:

Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[NSMutableArray objectAtIndex:]: index 6 beyond bounds [0 .. 5]'
*** Call stack at first throw:

I using this code:

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    // Return the number of rows in the section.

    int num_rows = 0;

    switch (section) {
        case 0:{
            num_rows = [messageReceive count];
        }
            break;
        case 1:{
            num_rows = [messageSend count];
        }
            break;


    return num_rows;    
}

but i try many code but the same error. I using a UITableView to get message from a script php with Json. In “messageReceive” sometimes i have 0 or 1 or many messages. the same for messageSend.

thx

this is my cellForRowAtIndexPath

// Configure the cell.


    NSDictionary * dictMessReceive = [self.messageReceive objectAtIndex:indexPath.row];
    NSDictionary * dictMessSend = [self.messageSend objectAtIndex:indexPath.row];

    switch ( indexPath.section )
    {
        case 0: 
            if (pseudoLabel.text =[dictMessSend  objectForKey:@"sender"] )

    {cell.detailTextLabel.text = [dictMessSend  objectForKey:@"receiver"];
    cell.text= [dictMessSend  objectForKey:@"message"];
            }
            break;


        case 1:             
            if (pseudoLabel.text =[dictMessReceive  objectForKey:@"receiver"] ) 
            {cell.detailTextLabel.text = [dictMessReceive  objectForKey:@"sender"];
        cell.text= [dictMessReceive  objectForKey:@"message"];

                }

            else {
                //cell.text = @"No message";
            }

            break;

    }   


    return cell;
  • 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-23T08:28:06+00:00Added an answer on May 23, 2026 at 8:28 am

    Where is the exception being raised? No where in the code you posted could that exception be raised unless you implemented a custom count method. So I will assume the exception is being raised in tableView:cellForRowAtIndexPath:. Inside of that method (or any other similar methods) make sure you use the same logic.

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
        switch (indexPath.section) {
            case 0:{
                //messageReceive logic
            }
            break;
            case 1:{
                //messageSend logic
            }
            break;
        }
    }
    

    Next thing you want to do is make sure that messageReceive and messageSend are not mutable (your console output shows it was mutable). If they are properties then they should be an NSArray and set to copy not retain (ex. @property(nonatomic, copy) NSArray *messageReceive; otherwise the code should look like messageReceive = [sourceArray copy];

    Update:

    The update you provide shows the problem is on the following line

    NSDictionary * dictMessReceive = [self.messageReceive objectAtIndex:indexPath.row];
    NSDictionary * dictMessSend = [self.messageSend objectAtIndex:indexPath.row];
    

    You can not access both arrays with the same index, move that into the switch statement

    NSDictionary * dictMessReceive = nil;
    NSDictionary * dictMessSend = nil;
    
    switch ( indexPath.section )
    {
        case 0: 
            dictMessageReceive = [self.messageReceive objectAtIndex:indexPath.row];
            //...
            break;
        case 1:
            dictMessSend = [self.messageSend objectAtIndex:indexPath.row];
            //...
            break;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have limited experience with .net. My app throws an error this.dateTimeFormat is undefined
I get this error when running my iPhone app 2009-12-05 21:32:06.711 iTour[7595:207] *** Terminating
I get the following error when i open this xcode project I have tried
I have this error when building and running my project in xCode: RootViewController may
When I analyse my code with Xcode,I have this error: Thx for help.
I have got this error when using Enterprise Library 3.1 May 2007 version. We
I get this error:- You have an error in your SQL syntax; check the
I have been trying to get around this error for a day now and
NHibernate is driving me 'Nuts'!!! I have the following mapping. Which returns this error
I have a list of error codes I need to reference, kinda like this:

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.