6

How would I get notified of a value of a NSDatePicker, when it's changed?

prosseek
  • 182,215
  • 215
  • 566
  • 871
nanochrome
  • 707
  • 2
  • 12
  • 26

3 Answers3

4

I've only done it on the iPhone with UIDatePicker but it is similar on the Mac, you register as a delegate and receive messages. See Apple's Docs here.

I should clarify, this tells you when it changed, you still need to call -dateValue to get the date.

bmalicoat
  • 2,508
  • 3
  • 24
  • 23
4

The same you would any other control. Options are:

  • Target/Action
  • Binding
  • Observe notification
  • Delegate
Mike Abdullah
  • 14,933
  • 2
  • 50
  • 75
  • 1
    AS of 2016, NSDatePicker doesn't seem to send an action or run KVO (although the problem with the latter may be a bug in my code) – JeremyP Apr 13 '16 at 07:26
1

You can bind the picker's value binding to a property of your controller, or a property of a model object (through a controller).

Peter Hosey
  • 95,783
  • 15
  • 211
  • 370