<!--
{
  "availability" : [
    "iOS: 18.0.0 -",
    "iPadOS: 18.0.0 -",
    "macCatalyst: 18.0.0 -",
    "visionOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UICalendarSelectionWeekOfYear",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)UICalendarSelectionWeekOfYear"
  },
  "title" : "UICalendarSelectionWeekOfYear"
}
-->

# UICalendarSelectionWeekOfYear

An object that tracks a specific week a person selects from a calendar view.

```
@MainActor class UICalendarSelectionWeekOfYear
```

## Overview

Use the [`UICalendarSelectionWeekOfYear`](/documentation/UIKit/UICalendarSelectionWeekOfYear) selection behavior to allow selecting dates in a calendar view by week. The following code example shows how to configure a calendar view’s selection behavior to use week-of-year selection:

```swift
// Create a calendar view.
let calendarView = UICalendarView()
calendarView.calendar = Calendar(identifier: .gregorian)

// Set the selection behavior.
let selection = UICalendarSelectionWeekOfYear(delegate: self)
calendarView.selectionBehavior = selection

// Set the 11th week in the year 2024.
selection.selectedWeekOfYear = DateComponents(
    calendar: Calendar(identifier: .gregorian),
    weekOfYear: 11,
    yearForWeekOfYear: 2024)
```

## Topics

### Creating a week-of-year selection

[`init(delegate: (any UICalendarSelectionWeekOfYearDelegate)?)`](/documentation/UIKit/UICalendarSelectionWeekOfYear/init(delegate:))

Creates an object that tracks a week a person selects from a calendar view, with an optional delegate to manage selectable weeks and selection changes.

### Setting the selection delegate

[`var delegate: (any UICalendarSelectionWeekOfYearDelegate)?`](/documentation/UIKit/UICalendarSelectionWeekOfYear/delegate)

A delegate object that a calendar view asks about selectable weeks and informs of changes to the week selection.

[`protocol UICalendarSelectionWeekOfYearDelegate`](/documentation/UIKit/UICalendarSelectionWeekOfYearDelegate)

A set of methods you implement to provide selectable weeks and handle changes to the week selection in a calendar view.

### Updating the selected week

[`var selectedWeekOfYear: DateComponents?`](/documentation/UIKit/UICalendarSelectionWeekOfYear/selectedWeekOfYear)

The current week-of-year selection in the calendar view.

[`func setSelected(DateComponents?, animated: Bool)`](/documentation/UIKit/UICalendarSelectionWeekOfYear/setSelected(_:animated:))

Updates the date component object that represents a selected week in a calendar view, with an option to animate the change.

## Relationships

### Inherits From

[`UICalendarSelection`](/documentation/UIKit/UICalendarSelection)

### Conforms To

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

[`Sendable`](/documentation/Swift/Sendable)

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

[`CVarArg`](/documentation/Swift/CVarArg)

[`Hashable`](/documentation/Swift/Hashable)

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

[`Equatable`](/documentation/Swift/Equatable)

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)