text entry problem with NSDateFormatter
text entry problem with NSDateFormatter
- Subject: text entry problem with NSDateFormatter
- From: Alex Rice <email@hidden>
- Date: Wed, 12 Dec 2001 14:12:24 -0700
When I programmatically assign an NSDateFormatter to a text field or a
tableview datacell, it correctly displays using the user's local, but
the text entry is messed up and the user can't type in dates formatted
using their locale. Here is some example code which shows how I'm
setting up the formatters:
aDateFormatter = [[[NSDateFormatter alloc] initWithDateFormat:
[[NSUserDefaults standardUserDefaults]
objectForKey:NSShortDateFormatString]
allowNaturalLanguage:NO] retain];
[[[aTableView tableColumnWithIdentifier:@"dateDue"] dataCell]
setFormatter: aDateFormatter];
anotherDateFormatter = [[[NSDateFormatter alloc] initWithDateFormat:
[[NSUserDefaults standardUserDefaults]
objectForKey:NSShortDateFormatString]
allowNaturalLanguage:NO] retain];
[aTextField setFormatter: anotherDateFormatter];
Now, if the user has for instance, Finnish for their date format
preferences, the TextField or tableview data cell will display dates
with the appropriate Day.Month.Year format, but won't allow data entry
in the Day.Month.Year format. This of course frustrates the
international users. What am I missing here, or is this a bug in Cocoa
text system?
Thanks,
Alex Rice <email@hidden>
Mindlube Software
http://www.mindlube.com/