Skip navigation.
 
mlRe: Short Date Format for NSCalendarDate in bound NSTableColumn
FROM : Jonathan Fewtrell
DATE : Sat Apr 16 18:55:46 2005

On 16 Apr 2005, at 17:49, glenn andreas wrote:

>>>> I have an array of model objects displayed in an NSTableView
>>>> controlled via binding through an  NSArrayController. One of the
>>>> ivars of the model is of class NSCalendarDate and is bound to one
>>>> of the NSTableColumns.
>>>>
>>>> In basic form it displays OK, but the default date format is too
>>>> long. Unfortunately the NSDateFormatter included in IB cannot
>>>> handle the NSShortDateFormatString. There is no token for this (and
>>>> I want the short format to be as set by the user in System
>>>> Preferences, rather than imposing a format myself).
>>>>
>>>> So I thought I'd write a ValueTransformer instead. Here's the code:
>>>>

>>>
>>> Not that this directly solves the problem you're seeing, but as an
>>> alternate approach you could write your own NSDateFormatter subclass
>>> instead

>>
>> Thanks for the suggestion. I may have to do that, but I think that
>> means I'd need to attach the formatter programatically to each date
>> column (I have several). I was hoping to avoid setting up all those
>> outlets and connections.
>>

>
> You don't need to do that - you can do it all in IB.
>
> Drag the default date formatter and drop it on the column, which will
> format the column with the undesired long format.
>
> Switch your nib window to the outline view, and tunnel through the
> outline until you find your scroll view > table view > table column,
> which should have an NSDateFormatter inside it.  Select that item, go
> to the Custom Subclass panel, select your new subclass.  Done.
>
> (This trick works in other places that have formatters as well,
> besides table columns)


Fantastic! Never thought of that. Many thanks.

Related mailsAuthorDate
mlShort Date Format for NSCalendarDate in bound NSTableColumn Jonathan Fewtrell Apr 16, 18:06
mlRe: Short Date Format for NSCalendarDate in bound NSTableColumn glenn andreas Apr 16, 18:17
mlRe: Short Date Format for NSCalendarDate in bound NSTableColumn Jonathan Fewtrell Apr 16, 18:44
mlRe: Short Date Format for NSCalendarDate in bound NSTableColumn glenn andreas Apr 16, 18:49
mlRe: Short Date Format for NSCalendarDate in bound NSTableColumn Jonathan Fewtrell Apr 16, 18:55
mlRe: Short Date Format for NSCalendarDate in bound NSTableColumn Jonathan Fewtrell Apr 16, 19:59