Question

I have an NSPopUpButton's content bound to an Array Controller of "Meeting" entities and it's content value bound to the same array controller, but to the "date" model key path. Everything works fine. But I'd like to format the way the date is displayed with an NSDateFormatter and I can't get it to work. Any hints? Is it even possible?

Was it helpful?

Solution

OK, some guys on Twitter suggested adding a formattedDate method to my model. I knew from the get go that I could do that but was hoping that there's some IB-only solution. I don't think there is, so to answer my own question: NSDateFormatter doesn't (seem to) work with NSPopUpButton.

My formattedDate method looks like this:

- (NSString *)formattedDate {
  return [NSDateFormatter localizedStringFromDate:self.date dateStyle:NSDateFormatterLongStyle timeStyle:NSDateFormatterNoStyle];
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top