• 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
Re: NSDateFormatter problem using NSShortDateFormatString
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Follow-Ups:
    • Re: NSDateFormatter problem using NSShortDateFormatString
      • From: Will Cosgrove <email@hidden>
References: 
 >NSDateFormatter problem using NSShortDateFormatString (From: Will Cosgrove <email@hidden>)

  • Prev by Date: Main Menu : Beginner's question
  • Next by Date: Re: Get default Browser and Mail Client
  • Previous by thread: NSDateFormatter problem using NSShortDateFormatString
  • Next by thread: Re: NSDateFormatter problem using NSShortDateFormatString
  • Index(es):
    • Date
    • Thread