DateFormatter in outlineview cell....(again sorry!)
DateFormatter in outlineview cell....(again sorry!)
- Subject: DateFormatter in outlineview cell....(again sorry!)
- From: Keith Pritchard <email@hidden>
- Date: Tue, 1 Oct 2002 17:20:26 +0100
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.