• 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
Short Date Format for NSCalendarDate in bound NSTableColumn
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Short Date Format for NSCalendarDate in bound NSTableColumn


  • Subject: Short Date Format for NSCalendarDate in bound NSTableColumn
  • From: Jonathan Fewtrell <email@hidden>
  • Date: Sat, 16 Apr 2005 17:06:00 +0100

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:

+ (Class)transformedValueClass
{
return [NSString class];
}

+ (BOOL)allowsReverseTransformation
{
return NO;
}

- (id)value
{
NSString *format;


format = [[NSUserDefaults standardUserDefaults] stringForKey:NSShortDateFormatString];
return [value descriptionWithCalendarFormat:format];
}

The last line causes an exception: -[NSCFDate descriptionWithCalendarFormat:]: selector not recognized.

Why? It seems that my NSCalendarDate has become an NSCFDate and the latter does not respond to -descriptionWithCalendarFormat. Why would that happen?
 _______________________________________________
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: Short Date Format for NSCalendarDate in bound NSTableColumn
      • From: glenn andreas <email@hidden>
  • Prev by Date: Re: NSArrayController - Mutability lost?
  • Next by Date: Re: Short Date Format for NSCalendarDate in bound NSTableColumn
  • Previous by thread: RE: Placing controls inside a table header view? (Solution)
  • Next by thread: Re: Short Date Format for NSCalendarDate in bound NSTableColumn
  • Index(es):
    • Date
    • Thread