• 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
Displaying date in Core Data application
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Displaying date in Core Data application


  • Subject: Displaying date in Core Data application
  • From: Wayne Pascoe <email@hidden>
  • Date: Tue, 4 Apr 2006 09:42:20 +0100

Hi all,

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 :)

--
Wayne Pascoe    (gpg --keyserver www.co.uk.pgp.net --recv-keys 79A7C870)
What we need is either less corruption, or more
chance to participate in it.

Attachment: PGP.sig
Description: This is a digitally signed message part

 _______________________________________________
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

  • Follow-Ups:
    • Re: Displaying date in Core Data application
      • From: mmalcolm crawford <email@hidden>
    • Re: Displaying date in Core Data application
      • From: Paul Lynch <email@hidden>
  • Prev by Date: NSXMLDTD
  • Next by Date: NSProgressIndicator, runModalForWindow, detachNewThreadSelector -> Not good...
  • Previous by thread: Re: NSXMLDTD
  • Next by thread: Re: Displaying date in Core Data application
  • Index(es):
    • Date
    • Thread