Re: NSDateFormatter problem using NSShortDateFormatString
Re: NSDateFormatter problem using NSShortDateFormatString
- Subject: Re: NSDateFormatter problem using NSShortDateFormatString
- From: Robert Cerny <email@hidden>
- Date: Mon, 16 Sep 2002 08:57:19 +0200
Hi,
at first, you should check in the debugger that formatter gets
initialized in time of allocation. If so, it's important if
icValueField already has any formatter attached because you should
release it before using another one. (You can simply do it by sending
[icValueField setFormatter:nil]). Also, I would recommend to create a
new NSCalendarDate instance and fill the icValueField programatically,
just to check your formatter.
NSString *format;
NSDateFormatter *formatter;
format = [[NSUserDefaults standardUserDefaults]
stringForKey:NSShortDateFormatString];
formatter = [[NSDateFormatter alloc] initWithDateFormat:format
allowNaturalLanguage:YES];
//attach to editfield
[icValueField setObjectValue:[NSCalendarDate date]];
[icValueField setFormatter:nil];
[icValueField setFormatter: formatter];
HTH
Robert
On Friday, Sep 13, 2002, at 21:32 Europe/Prague, Will Cosgrove wrote:
Hi All,
I have, what would seem to be, a simple question. I would like to set
up a date formatter that uses the correct short date format from the
International Prefs settings so I don't *inflict* the US date format
on UK users for example. I'm trying to use NSShortDateFormatString
and pass that into my formatter like so:
NSString *format
NSDateFormatter *formatter;
format = [[NSUserDefaults standardUserDefaults]
stringForKey:NSShortDateFormatString];
formatter = [[NSDateFormatter alloc] initWithDateFormat:format
allowNaturalLanguage:NO];
//attach to editfield
[icValueField setFormatter: formatter];
However, this absolutely doesn't work. It never accepts any input as
valid. Does anyone know how I can get this working, I'm at a loss.
It seems the format string is malformed or something like that.
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.
_______________________________________________
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.