Re: DateFormatter in outlineview cell....(again sorry!)
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.