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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T22:00:39+00:00 2026-06-09T22:00:39+00:00

In my application I have a UITableView and some buttons that the user can

  • 0

In my application I have a UITableView and some buttons that the user can click to sort the array to the order based upon some NSDate’s or ints. So this is my method to try to sort my UITableView:

- (void)sortStats:(id)sender reloadData:(BOOL)dataBool {
    NSSortDescriptor *descriptor = nil;
    UIButton *clickedButton = (UIButton*)sender;
    if (clickedButton.tag == 1) {
            descriptor = [NSSortDescriptor sortDescriptorWithKey:@"Date" ascending:NO];
    }
    [self.cellArray sortUsingDescriptors:[NSArray arrayWithObject:descriptor]];
    [[NSUserDefaults standardUserDefaults] setObject:self.cellArray forKey:@"cellArray"];
    if (dataBool) {
        [ivstatstableView reloadData];
    }
    [ivstatstableView scrollRectToVisible:CGRectMake(0, 0, 1, 1) animated:YES];
}

So originally I just had this method without the reloadData parameter because it seemed that reloadData on the UITableView was causing the crash.

This is what the console crash log is:

Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: ‘*** -[__NSPlaceholderArray initWithObjects:count:]: attempt to insert nil object from objects[0]’

Anyway is there any code here that would be causing this crash? I really want to get this functionality working in my app and I know I am close to fixing it but I am just not sure whats causing this issue.

Any ideas?

  • 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-09T22:00:41+00:00Added an answer on June 9, 2026 at 10:00 pm

    There is at least one place where this could be happening, and perhaps others. In the code where you get the contents of the user defaults, you don’t check for nil. So instead of this:

    [self.cellArray addObjectsFromArray:[[NSUserDefaults standardUserDefaults] objectForKey:@"array"]];
    

    you might want to try this:

    NSArray *defaultCellArray = [[NSUserDefaults standardUserDefaults] objectForKey:@"array"];
    if (defaultCellArray) {
        [self.cellArray addObjectsFromArray:defaultCellArray];
    }
    

    It is also possible that the initWithObjects call that is failing (according to your error message) is nested within another call, perhaps in this call:

    [self.cellArray sortUsingDescriptors:[NSArray arrayWithObject:descriptor]];
    

    If you look at the full call stack it would tell you if this call is making subsequent calls to initWithObjects and possibly passing it a nil. In your case, for example, you would pass in a nil yo the array you are creating if clickedButton.tag has not yet been set to a value of 1 or 2. You might want to add an additional else clause to help diagnose the problem:

    if (clickedButton.tag == 1) {
            descriptor = [NSSortDescriptor sortDescriptorWithKey:@"Date" ascending:NO];
    } else if (clickedButton.tag == 2) {
            descriptor = [NSSortDescriptor sortDescriptorWithKey:@"Score" ascending:NO];
    } else {
        NSLog(@"Unexpected error: Can't determine sort descriptor");
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an application with multiple views. I can click on different buttons to
I have made a view in the application that shows a UITableView. It will
So, I have this UITableView . It's in an iPad application. Some of the
I have a UITableView in an iPad application that I am working on. When
I have an application that works some what similar to how iPhone's Contact application
How can I make an iphone application that uses a UITableView but so the
I have simple application with list of movies in UITableView. When I select some
I have an application that has a UITableView. This UITableView is populated by an
I see an application have used Log.info = some info where are these logs
In My application have time consuming process.There fore i try to do that operation

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.