Re: Displaying date in Core Data application
Re: Displaying date in Core Data application
- Subject: Re: Displaying date in Core Data application
- From: Paul Lynch <email@hidden>
- Date: Tue, 4 Apr 2006 09:58:23 +0100
You can use a date formatter (from the IB palette) on your cell; just
drop it on your table column. I suspect that you can have the same
general effect with a value transformer, but the formatter seems
simpler to me.
Your approach isn't a bad one, if you need access to a formatted
string elsewhere outside of the UI.
Paul
On 4 Apr 2006, at 09:42, Wayne Pascoe wrote:
I have a core data application that uses an NSDate field. I am
displaying this field in an NSTableColumn. When the application
runs, the full date, including time is displayed.
In my edit inspector panel, I have used a date picker to allow
editing of the date, and this was easy to change to only display
the day, month and year.
What is the right way to change my NSTableColumn to just display
the day, month and year?
At the moment, I have a bit of a hack for this. I have used a
custom class for the entity that contains the date, and added an
awakeFromInsert method. This method. I have also added a String
attribute to the entity named displayDate. In my awakeFromInsert
method, I am setting the displayDate attribute as follows:
[self setValue:[NSDate date] forKey:@"date"];
[self setValue:[[NSDate date] descriptionWithCalendarFormat:@"%Y-%m-
%d"
timeZone:nil
locale:nil] forKey:@"displayDate"];
I will also have to add a didChangeValueForKey:@"date" method
somewhere to change the display date on updates.
This all seems a bit long winded, and I can't help but feel that
there must be a simpler way of doing this. If anyone could point me
at that way, I would be grateful :)
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden