• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
NSDateFormatter problems
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSDateFormatter problems


  • Subject: NSDateFormatter problems
  • From: Will Cosgrove <email@hidden>
  • Date: Wed, 20 Nov 2002 16:47:17 -0600

Hi All,
I've having some major problems with NSDateFormatter and I was wondering if anyone had some suggestions. I'm trying to get the localized short date from NSUserDefaults, then set a formatter with it and allow the formatted NSTableViewColumn cell to be editable. This is the code I'm using:

NSString* formatString = [NSString stringWithString: [[NSUserDefaults standardUserDefaults] objectForKey:NSShortDateFormatString]];

dateFormatter = [[NSDateFormatter alloc] initWithDateFormat:formatString allowNaturalLanguage:NO];

//setting the table column's data cell formatter - which I know is valid.
[[column dataCell] setFormatter: formatter];
(snip stuff)
[column setEditable: YES];

This works great to format the column's date to the localized value. But after I set the cell's formatter I can't exit editing the cell because the formatter ALWAYS fails when validating the date format. I would imagine it thinks the format of the new value in the cell is invalid, but it's not. However, if I set the formatter up with a string like so:

dateFormatter = [[NSDateFormatter alloc] initWithDateFormat:@"%m/%d/%y" allowNaturalLanguage:NO];

It works the way it should. Does anyone have any idea why this would be failing, it's driving me crazy.

Thanks in advance.
Will C.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: NSDateFormatter problems
      • From: Fritz Anderson <email@hidden>
  • Prev by Date: Re: Table View Blues (summary), or, allocWithZone not working
  • Next by Date: Re: Setting the subclass for an NSTextView... in IB..
  • Previous by thread: Re: Table View Blues (summary), or, allocWithZone not working
  • Next by thread: Re: NSDateFormatter problems
  • Index(es):
    • Date
    • Thread