NSDatePicker Class Reference

Inherits from
Conforms to
Framework
/System/Library/Frameworks/AppKit.framework
Availability
Available in OS X v10.4 and later.
Declared in
NSDatePicker.h
Related sample code

Overview

NSDatePicker is a subclass of NSControl that provides a user interface for displaying and editing an NSDate object.

NSDatePicker uses an NSDatePickerCell to implement much of the control’s functionality. NSDatePicker provides cover methods for most of NSDatePickerCell methods, which invoke the corresponding cell method.

Tasks

Configuring Date Pickers

Controlling Date Picker Range and Mode

Accessing Object Values

Constraining the Displayable/Selectable Range

Instance Methods

backgroundColor

Returns the background color of the receiver.

- (NSColor *)backgroundColor
Return Value

The background color of the receiver.

Availability
  • Available in OS X v10.4 and later.
Declared In
NSDatePicker.h

calendar

Returns the calendar used by the receiver.

- (NSCalendar *)calendar
Return Value

The calendar used by the receiver.

Availability
  • Available in OS X v10.4 and later.
Declared In
NSDatePicker.h

datePickerElements

Returns a bitmask that indicates which visual elements of the date picker are currently shown, and which won't be usable because they are hidden.

- (NSDatePickerElementFlags)datePickerElements
Return Value

A bitmask that specifies the date picker elements displayed by the receiver. See “Constants” in NSDatePickerCell for a description of the possible values.

Availability
  • Available in OS X v10.4 and later.
Related Sample Code
Declared In
NSDatePicker.h

datePickerMode

Returns the receiver’s date picker mode.

- (NSDatePickerMode)datePickerMode
Return Value

The receiver’s date picker mode.

Availability
  • Available in OS X v10.4 and later.
Declared In
NSDatePicker.h

datePickerStyle

Returns the receiver’s date picker style.

- (NSDatePickerStyle)datePickerStyle
Return Value

The receiver’s date picker style.

Availability
  • Available in OS X v10.4 and later.
Related Sample Code
Declared In
NSDatePicker.h

dateValue

Returns the receiver’s date.

- (NSDate *)dateValue
Return Value

The receiver’s date.

Availability
  • Available in OS X v10.4 and later.
Related Sample Code
Declared In
NSDatePicker.h

delegate

Returns the delegate of the receiver’s date picker cell.

- (id)delegate
Return Value

The delegate of the receiver’s date picker cell.

Discussion

The date picker’s NSDatePickerCell instance handles all delegate methods.

Availability
  • Available in OS X v10.4 and later.
Declared In
NSDatePicker.h

drawsBackground

Returns whether the receiver draws the background.

- (BOOL)drawsBackground
Return Value

TRUE if the receiver draws the background, FALSE otherwise.

Availability
  • Available in OS X v10.4 and later.
Declared In
NSDatePicker.h

isBezeled

Returns whether the receiver has a bezeled border.

- (BOOL)isBezeled
Return Value

TRUE if the receiver has a bezeled border, FALSE otherwise.

Availability
  • Available in OS X v10.4 and later.
Declared In
NSDatePicker.h

isBordered

Returns whether the receiver has a plain border.

- (BOOL)isBordered
Return Value

TRUE if the receiver has a plain border, FALSE otherwise.

Availability
  • Available in OS X v10.4 and later.
Declared In
NSDatePicker.h

locale

Returns the receiver’s locale.

- (NSLocale *)locale
Return Value

The receiver’s locale.

Availability
  • Available in OS X v10.4 and later.
Declared In
NSDatePicker.h

maxDate

Returns the maximum date value the receiver allows as input.

- (NSDate *)maxDate
Return Value

The maximum date value the receiver allows as input. nil indicates no maximum date.

Availability
  • Available in OS X v10.4 and later.
Declared In
NSDatePicker.h

minDate

Returns the minimum date value the receiver allows as input.

- (NSDate *)minDate
Return Value

The minimum date value the receiver allows as input. nil indicates no minimum date.

Availability
  • Available in OS X v10.4 and later.
Declared In
NSDatePicker.h

setBackgroundColor:

Sets the receiver’s background color.

- (void)setBackgroundColor:(NSColor *)color
Parameters
color

The new background color.

Availability
  • Available in OS X v10.4 and later.
Related Sample Code
Declared In
NSDatePicker.h

setBezeled:

Specifies whether the receiver draws a bezeled border.

- (void)setBezeled:(BOOL)flag
Parameters
flag

TRUE if the receiver has a bezeled border, FALSE otherwise.

Availability
  • Available in OS X v10.4 and later.
Related Sample Code
Declared In
NSDatePicker.h

setBordered:

Specifies whether the receiver draws a plain border.

- (void)setBordered:(BOOL)flag
Parameters
flag

TRUE if the receiver has a plain border, FALSE otherwise.

Availability
  • Available in OS X v10.4 and later.
Related Sample Code
Declared In
NSDatePicker.h

setCalendar:

Sets the receiver’s calendar.

- (void)setCalendar:(NSCalendar *)newCalendar
Parameters
newCalendar

The new calendar.

Availability
  • Available in OS X v10.4 and later.
See Also
Declared In
NSDatePicker.h

setDatePickerElements:

Sets a bitmask that indicates which visual elements of the date picker are currently shown, and which won't be usable because they are hidden.

- (void)setDatePickerElements:(NSDatePickerElementFlags)elementFlags
Parameters
elementFlags

A bitmask that specifies the date picker elements displayed by the receiver. See “Constants” in NSDatePickerCell for a description of the possible values.

Availability
  • Available in OS X v10.4 and later.
Related Sample Code
Declared In
NSDatePicker.h

setDatePickerMode:

Sets the receiver’s date picker mode.

- (void)setDatePickerMode:(NSDatePickerMode)newMode
Parameters
newMode

The new date picker mode.

Availability
  • Available in OS X v10.4 and later.
Related Sample Code
Declared In
NSDatePicker.h

setDatePickerStyle:

Sets the receiver’s date picker style.

- (void)setDatePickerStyle:(NSDatePickerStyle)newStyle
Parameters
newStyle

The new date picker style.

Availability
  • Available in OS X v10.4 and later.
Related Sample Code
Declared In
NSDatePicker.h

setDateValue:

Sets the receiver’s date to a new starting value.

- (void)setDateValue:(NSDate *)newStartDate
Parameters
newStartDate

The new starting date.

Availability
  • Available in OS X v10.4 and later.
Related Sample Code
Declared In
NSDatePicker.h

setDelegate:

Sets the delegate of the receiver’s date picker cell.

- (void)setDelegate:(id)anObject
Parameters
anObject

The new delegate.

Discussion

The date picker’s NSDatePickerCell instance handles all delegate methods.

Availability
  • Available in OS X v10.4 and later.
See Also
Related Sample Code
Declared In
NSDatePicker.h

setDrawsBackground:

Specifies whether the receiver draws the background.

- (void)setDrawsBackground:(BOOL)flag
Parameters
flag

TRUE if the receiver draws the background, FALSE otherwise.

Availability
  • Available in OS X v10.4 and later.
Related Sample Code
Declared In
NSDatePicker.h

setLocale:

Sets the receiver’s locale.

- (void)setLocale:(NSLocale *)newLocale
Parameters
newLocale

The new locale.

Availability
  • Available in OS X v10.4 and later.
See Also
Declared In
NSDatePicker.h

setMaxDate:

Sets the maximum date allowed as input by the receiver.

- (void)setMaxDate:(NSDate *)date
Parameters
date

The maximum date allowed as input by the receiver. nil indicates no maximum date.

Availability
  • Available in OS X v10.4 and later.
See Also
Related Sample Code
Declared In
NSDatePicker.h

setMinDate:

Sets the minimum date allowed as input by the receiver.

- (void)setMinDate:(NSDate *)date
Parameters
date

The minimum date allowed as input by the receiver. nil indicates no minimum date.

Availability
  • Available in OS X v10.4 and later.
See Also
Related Sample Code
Declared In
NSDatePicker.h

setTextColor:

Sets the text color of the receiver.

- (void)setTextColor:(NSColor *)color
Parameters
color

The new text color.

Availability
  • Available in OS X v10.4 and later.
Related Sample Code
Declared In
NSDatePicker.h

setTimeInterval:

Sets the time interval of the date range.

- (void)setTimeInterval:(NSTimeInterval)newTimeInterval
Parameters
newTimeInterval

The new time interval.

Discussion

The time interval only applies when the receiver is in the NSRangeDateMode mode.

Availability
  • Available in OS X v10.4 and later.
Declared In
NSDatePicker.h

setTimeZone:

Sets the receiver’s time zone.

- (void)setTimeZone:(NSTimeZone *)newTimeZone
Parameters
newTimeZone

The new time zone.

Availability
  • Available in OS X v10.4 and later.
See Also
Declared In
NSDatePicker.h

textColor

Returns the text color of the receiver.

- (NSColor *)textColor
Return Value

The text color of the receiver.

Availability
  • Available in OS X v10.4 and later.
Declared In
NSDatePicker.h

timeInterval

Returns the time interval that represents the date range.

- (NSTimeInterval)timeInterval
Return Value

The time interval that represents the receiver’s date range. The date range begins at the date returned by dateValue. This method returns 0 when the receiver is not in the NSRangeDateMode mode.

Special Considerations

Prior to OS X v 10.5, this method always returned 0.

Availability
  • Available in OS X v10.4 and later.
Declared In
NSDatePicker.h

timeZone

Returns the receiver’s time zone.

- (NSTimeZone *)timeZone
Return Value

The receiver’s time zone.

Availability
  • Available in OS X v10.4 and later.
Declared In
NSDatePicker.h