Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSDateFormatter in View based NSTableView

I can't figure out how to set an NSDateFormatter for a static text table cell view in Interface Builder using the new view based NSTableViews. Since the problem is Interface Builder related, here are the steps to recreate the setup in Interface Builder:

  1. Create Table View
  2. Change Content Mode to View Based, name one column Date and have it contain static text views.
  3. Fill the table with some test data (one column should contain dates)
  4. Create a NSDateFormatter, in settings, set the Date Style to Short Style
  5. Open the Static Text View for our date and set the formatter to the NSDateFormatter.

I seem to always get the default date formatting. How do I apply the date format to the dates in the table?

like image 928
cellcortex Avatar asked Feb 05 '12 23:02

cellcortex


1 Answers

The solution was actually very simple with the latest XCode 4.3.1:

  • In Interface Builder, drag a Date Formatter into the target cell (so it becomes it's child)
  • Set the date format for the Date Formatter

No additional wiring was required. Hope this helps somebody else running into this.

like image 126
cellcortex Avatar answered Oct 15 '22 05:10

cellcortex