1

I've got a Core Data application that has an Event class, which has a start date and a finish date. It's trivial to bind these to a pair of NSDatePicker widgets, but I wanted to make it work with the NSRangeDateMode available in Leopard.

The NSDatePicker has a pair of methods that deal with timeInterval, but I don't seem to be able to bind to this.

Update: I've used a manual call to do the binding, and it half works:

[picker bind:@"timeInterval" 
    toObject:array 
 withKeyPath:@"selection.timeInterval" 
     options:options];

It sets the timeInterval in the NSDatePicker when the underlying object is changed, but does not set the underlying object when the NSDatePicker's timeInterval is changed.

Matthew Schinckel
  • 35,041
  • 6
  • 86
  • 121

3 Answers3

1

The interval support is only available when you're using the graphical version of the date picker. Even then, there's no native binding support for timeInterval.

Also depending on how you're intending to use this the UI to select ranges that extend past the current month is poor in my opinion.

Ashley Clark
  • 8,813
  • 3
  • 35
  • 35
1

Sadly, no. The timeInterval property of the date picker is not even properly key-value observable. Basically, you're stuck either setting up an action method or using the delegate validation method to receive updates to its value. Also, you'll want to round it off to the nearest multiple of 86400.0 (i.e. the number of seconds in a day), since the date picker is consistently off by some fraction of a second in its reported timeInterval. Perhaps by the time Snow Leopard rolls around, this feature will be fully baked.

Boaz Stuller
  • 2,534
  • 21
  • 16
  • This suggestion made me think about how to get it to work - I have subclassed NSDatePickerCell, and tried to make it fully KVO compliant for timeInterval, but this resulted in an infinite loop. I'll try the delegate validation method (which I had used first, as it turns out). – Matthew Schinckel Dec 11 '08 at 00:17
0

1169097 explains how to implement custom bindings.

Community
  • 1
  • 1
yakovlev
  • 610
  • 6
  • 10