---
title: "setValue(_:for:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/datecomponents/setvalue(_:for:)"
---

# setValue(_:for:)

Set the value of one of the properties, using an enumeration value instead of a property name.

## Declaration

```swift
mutating func setValue(_ value: Int?, for component: Calendar.Component)
```

## Discussion

Discussion The calendar and timeZone and isLeapMonth properties cannot be set by this method.

## See Also

### Accessing Calendar Components

- [value(for:)](foundation/datecomponents/value(for:).md)
- [Calendar.Component](foundation/calendar/component.md)
