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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:31:37+00:00 2026-05-23T12:31:37+00:00

The NSMutableArray (inboxFaxItems)consists of strings set up like: MM/DD/YYYY hh:mm:ss a for example: 2/2/2011

  • 0

The NSMutableArray (inboxFaxItems)consists of strings set up like: MM/DD/YYYY hh:mm:ss a
for example:
2/2/2011 2:46:39 PM
2/4/2011 11:59:47 AM

I need to be able to sort this array so that the newest dates are at the top.

#import <UIKit/UIKit.h>


@interface InboxTableViewController : UITableViewController<NSXMLParserDelegate> {


    //all of these need to be put in custom class
    NSMutableArray *inboxFaxItems;
    NSMutableArray *dateArray;
    NSMutableArray *inboxMessageID;
    NSMutableArray *inboxMessagePageCount;
    NSMutableArray *inboxMessageFrom;



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

}


-(void) loadInbox;

@end



- (void)dealloc {
    [inboxFaxItems release];
    inboxFaxItems = nil;

    [inboxMessageID release];
    inboxMessageID = nil;

    [inboxMessagePageCount release];
    inboxMessagePageCount = nil;

    [inboxMessageFrom release];
    inboxMessageFrom = nil;

    [dateArray release];
    dateArray = nil;


    [super dealloc];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    // Return the number of rows in the section.
    return [dateArray count];
}

// 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];
    }

    // Configure the cell...

    [[cell textLabel]setText:[dateArray objectAtIndex:[indexPath row]]];
    cell.imageView.image = [UIImage imageNamed:@"document.png"];
    return cell;
}

- (void) connectionDidFinishLoading:(NSURLConnection *)connection{


    NSXMLParser *parser = [[NSXMLParser alloc]initWithData:xmlData];
    [parser setDelegate:self];
    [parser parse];
    [parser release];

    //do sorting here
    NSDateFormatter *formatter = [[[NSDateFormatter alloc] init] autorelease];
    [formatter setDateFormat:@"MM/DD/YYYY hh:mm:ss a"];

    for (NSString *dateString in inboxFaxItems) {
        NSDate *date = [formatter dateFromString:dateString];
        if (date) [dateArray addObject:date];
        // If the date is nil, the string wasn't a valid date.
        // You could add some error reporting in that case.
    }

    [[self tableView] reloadData];

    [connectionInprogress release];
    connectionInprogress = nil;

    [xmlData release];
    xmlData = nil;


}

However I am getting errors:

2011-06-29 02:49:28.782 app[4388:207] -[__NSDate isEqualToString:]: unrecognized selector sent to instance 0x4d9e090
2011-06-29 02:49:28.784 app[4388:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSDate isEqualToString:]: unrecognized selector sent to instance

OK THIS SEEMS TO HAVE FIXED IT: (UPDATE)

// 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];
    }

    NSDateFormatter *formatter = [[[NSDateFormatter alloc] init] autorelease];
    [formatter setDateFormat:@"MM/dd/yyyy hh:mm:ss a"];
    NSDate *date = [dateArray objectAtIndex:[indexPath row]];

    NSString *dateStr = @"";
    dateStr = [formatter stringFromDate:date];

    [[cell textLabel]setText:dateStr];
    cell.imageView.image = [UIImage imageNamed:@"document.png"];
    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-23T12:31:38+00:00Added an answer on May 23, 2026 at 12:31 pm

    Here’s your problem:

    [[cell textLabel] setText:[dateArray objectAtIndex:[indexPath row]]];
    

    setText: assumes it gets a string, and as such, when deciding wether or not to update itself, it sends an isEqualToString: method to the object it is passed, but SURPRISE!: It’s an NSDate object. Which doesn’t respond to that selector, obviously.

    What you need to do is to make a string from the date before you pass it to the label, and everything will come up roses.

    - (NSString *)descriptionWithLocale:(id)locale
    

    is probably the correct method for achieving this; but it’s possible that

    - (NSString *)description
    

    will do all the relevant locale stuff automagically.

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

Sidebar

Related Questions

I have an NSMutableArray saved with NSUserDefaults. This array is my favourite items that
I have An NSMutableArray of NSMutableDictionary Which Looks like this Object 1 of Array
I have an NSMutableArray that is populated with objects of strings. For simplicity sake
Why NSMutableArray element is not being deallocated when it is added like this: [map
I have this NSMutableArray which is a collection of objects that are being moved
Is there something like NSMutableArray that will take doubles directly without putting them inside
Using an NSMutableArray ivar, I plan to write a class that acts like a
I have two simple NSMutableArray that consists of few objects. Some of these objects
NSMutableArray *a1 = [[NSMutableArray alloc] init]; NSMutableArray *a2 = [NSMutableArray array]; TempObj *obj =
NSMutableArray *output = [[NSMutableArray alloc]init]; or NSArray *output = [[NSMutableArray alloc]init]; I can set

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.