Search code examples
cocoacore-datanspredicateeditor

Modifying NSDatePicker for automatically generated predicate row templates


How can I modify the NSDatePickerElementFlags for the NSDatePicker in row templates for NSDate properties returned by [NSPredicateRowEditorTemplate templatesWithAttributeKeyPaths:inEntityDescription:]? I would like the NSDatePicker to show hrs:minutes as well as the date.

Update I've added an answer below, gleaned from the cocoa-dev list.


Solution

  • Per Peter Ammon, on cocoa-dev, and as Ben notes, the easiest way is to modify the date picker in -templateViews directly:

    [[[template templateViews] objectAtIndex:2] setDatePickerElements:...]
    

    According to Peter, the order of elements in -templateViews is guaranteed to be constant.