Instance Method

setValue(_:forComponent:)

Sets a value for a given calendar unit.

Declaration

func setValue(_ value: Int, forComponent unit: NSCalendar.Unit)

Parameters

value

The value to set for the unit component.

unit

The calendar unit for which to set 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 set for an NSCalendar.Unit value.

See Also

Accessing Components as Calendrical Units

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

Returns the value for a given calendar unit.

struct NSCalendar.Unit

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

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software