2

Is there a generic control for picking and selecting time for Cocoa application (Mac Application Development)? For example, consider the case of a stop watch. The watch starts from 00:00:00.

The NSDatePicker seem to support "00:00:00 AM/PM" format only. I don't want "AM/PM", instead i want the control to support milliseconds e.g. "00:00:00,000". I may have to use set of NSTextFields alongside NSStepper controls, but a better solution (if available) would be preferred.

Mustafa
  • 20,504
  • 42
  • 146
  • 209

1 Answers1

1

You're right, NSDatePicker isn't customizable for milliseconds, and in any case it's not designed to show relative time, it's designed to show absolute time.

If you're happy to limit your stopwatch to 24 hours, then you can use a NSTextField with an attached NSDateFormatter with a format string of HH:mm:ss,SSS. Otherwise, you're on your own.

Nicholas Riley
  • 43,532
  • 6
  • 101
  • 124
  • 24 hours are enough. However, i can't seem to get this to work. I create an NSTextField attach an NSDateFormatter with a format string of hh:mm:ss,SSS. I can then assign a string/time e.g. 00:00:02,549 to this field, but when i go to edit the value, it doesn't let me leave this field. Any pointers as to why? I'm using setStringValue: method to set the value to the NSTextField. – Mustafa Aug 23 '11 at 03:35