• 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: DateFormatter in outlineview cell....(again sorry!)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: DateFormatter in outlineview cell....(again sorry!)


  • Subject: Re: DateFormatter in outlineview cell....(again sorry!)
  • From: Keith Pritchard <email@hidden>
  • Date: Tue, 1 Oct 2002 18:38:04 +0100

Think I've just answered my own question....

I was passing it a string, which I thought is what it wanted... but I
guess it wanted a date (reasonable I guess!).

return [NSCalendarDate dateWithNaturalLanguageString:[item
objectForKey:@"date"]];

Seems to get it working.

sorry if it was a really simple problem... it's just... the examples
had formatting numbers on a text field and I didn't notice anyone
converting the string to a number to get the formatter to work on it...
must have missed something somewhere.

all the best,
Keith


On Tuesday, October 1, 2002, at 05:20 PM, Keith Pritchard wrote:

> Hi,
>
> I know its a bit of a repeat but something strange is going on.. still
> just getting a blank cell whenever my formatter is applied (whether
> via IB or programmatically).
>
> I must be doing something really fundamentally wrong but don't know
> what....
> Thanks for any ideas.. even if its debug tips..... Keith
>
> NSDateFormatter *formatter; (declared in .h)
>
> - (void) awakeFromNib
> {
> formatter = [[NSDateFormatter alloc]
> initWithDateFormat:@"%b %d %y" allowNaturalLanguage:YES];
> }
>
> Try and apply it to the date field of the outlineview....
>
> - (void)outlineView:(NSOutlineView *)outlineView
> willDisplayCell:(id)theCell forTableColumn:(NSTableColumn *)theColumn
> item:(id)item
> {
> if ([[theColumn identifier] isEqualToString:@"dateField"]) //right
> column??
> [theCell setFormatter:formatter];
> }
>
>
>
> //Attempt to display an error if format fails... seems to never get
> called
>
> -(BOOL)control:(NSControl *)control didFailToFormatString:(NSString
> *)string errorDescription:(NSString *)error
> {
> NSLog(@"oops formatting of %@ failed: %@,string",error);
> return NO;
>
> }
>
>
> - (id)outlineView:(NSOutlineView *)outlineView
> objectValueForTableColumn:(NSTableColumn *)col byItem:(id)item
> {
> if ([[col identifier] isEqualToString:@"numberField"]) return
> [item objectForKey:@"subject"];
> if ([[col identifier] isEqualToString:@"authorField"]) return
> [item objectForKey:@"name"];
> if ([[col identifier] isEqualToString:@"dateField"]) return
> @"12/12/02"; //Just to test
>
> }
_______________________________________________
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.

References: 
 >DateFormatter in outlineview cell....(again sorry!) (From: Keith Pritchard <email@hidden>)

  • Prev by Date: Source-level availability-macro tweaking
  • Next by Date: using frameworks containing java code.
  • Previous by thread: DateFormatter in outlineview cell....(again sorry!)
  • Next by thread: MEETING: MacOS Developer Meeting Davis, CA Fri. 10/11/02
  • Index(es):
    • Date
    • Thread