Instance Method

value(forComponent:)

Returns the value for a given calendar unit.

Declaration

func value(forComponent unit: NSCalendar.Unit) -> Int

Parameters

unit

The calendar unit for which to retrieve its value. Do not pass calendar or timeZone.

Return Value

The value for the given calendar unit.

Discussion

This method allows for component values to be retrieved for an NSCalendar.Unit value.

See Also

Accessing Components as Calendrical Units

func setValue(Int, forComponent: NSCalendar.Unit)

Sets a value for a given calendar unit.

struct NSCalendar.Unit

Calendrical units such as year, month, day and hour.