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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:58:42+00:00 2026-05-23T14:58:42+00:00

I am trying to sort a NSMutableArray based on an object it contains. I

  • 0

I am trying to sort a NSMutableArray based on an object it contains. I am getting an error on this line in the code segment below:

InboxItem * ptrInboxItem =  [sortedInboxFaxItems objectAtIndex:[indexPath row]];

#import <UIKit/UIKit.h>
@class InboxItem;


@interface InboxTableViewController : UITableViewController<NSXMLParserDelegate> {
    NSMutableArray *inboxFaxItems;
    NSArray * sortedInboxFaxItems;
    InboxItem *_inboxItem;

    NSMutableData *xmlData;
    NSURLConnection *connectionInprogress;
    NSMutableString *inboxFaxesString;
    UIActivityIndicatorView *activityIndicator;
}

@property(nonatomic,retain) InboxItem * inboxItem;

-(void) loadInbox;

@end

- (void) connectionDidFinishLoading:(NSURLConnection *)connection{
    NSXMLParser *parser = [[NSXMLParser alloc]initWithData:xmlData];
    [parser setDelegate:self];
    [parser parse];
    [parser release];

    //lets sort by messageID
    NSSortDescriptor *sortDescriptor;
    sortDescriptor = [[[NSSortDescriptor alloc] initWithKey:@"messageID" ascending:YES] autorelease];
    NSArray *sortDescriptors = [NSArray arrayWithObject:sortDescriptor];
    sortedInboxFaxItems = [inboxFaxItems sortedArrayUsingDescriptors:sortDescriptors]; 

    [[self tableView] reloadData];
    activityIndicator.stopAnimating;

    [connectionInprogress release];
    connectionInprogress = nil;

    [xmlData release];
    xmlData = nil;
}

// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView 
         cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    static NSString *CellIdentifier = @"InboxFaxItem";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    }

    //I AM GETTING ERROR HERE
    InboxItem * ptrInboxItem =  [sortedInboxFaxItems objectAtIndex:[indexPath row]];

    [[cell textLabel]setText: ptrInboxItem.datetime];
    cell.imageView.image = [UIImage imageNamed:@"document.png"];
    return cell;
}

#pragma mark -
#pragma mark Table view delegate

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    // Navigation logic may go here. Create and push another view controller.

    MyManager *sharedManager = [MyManager sharedManager];
    InboxItem * ptrInboxItem =  [sortedInboxFaxItems objectAtIndex:[indexPath row]];

    sharedManager.pages = ptrInboxItem.pages;
    sharedManager.from =ptrInboxItem.from;

    FaxViewController *faxViewController = [[FaxViewController alloc] initWithNibName:@"FaxViewController" bundle:nil];
    faxViewController.messageid=ptrInboxItem.messageID;
    faxViewController.navigationItem.title=@"View Fax";
    [self.navigationController pushViewController:faxViewController animated:YES];
    [faxViewController release];
}
  • 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-23T14:58:42+00:00Added an answer on May 23, 2026 at 2:58 pm

    It’s because of this line:

    sortedInboxFaxItems = [inboxFaxItems sortedArrayUsingDescriptors:sortDescriptors];
    

    You’re assigning an object you don’t own to an instance variable. Later, when you try to access it, that object has been deallocated, so your instance variable now points to garbage.

    You should change that line to this:

    [sortedInboxFaxItems release]; // Release any previous value
    sortedInboxFaxItems = [[inboxFaxItems sortedArrayUsingDescriptors:sortDescriptors] retain];
    

    All better.

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

Sidebar

Related Questions

I trying to sort this HashMap based on date in keys My Hash map:
I was trying to sort some xml with jquery, but this code doesn't affect
Trying to sort this array of objects according to (1) depth and (2) weight,
I am trying to sort a dict based on its key and return an
I am trying to sort a list using delegates but I am getting a
I'm trying to sort an array that would look something like this: (please ignore
Im just starting getting into Objective-C, i'm trying to sort an array so it
Trying to sort the array below by memnum in ascending order, and I'm a
I'm trying to sort a multidimensional object, and, after looking on php.net and around
I am trying to sort by date and get an error message about the

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.