<!--
{
  "availability" : [
    "iOS: 16.0.0 -",
    "iPadOS: 16.0.0 -",
    "macCatalyst: 16.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "DeviceActivity",
  "identifier" : "/documentation/DeviceActivity/DeviceActivityData/ActivitySegment/longestActivity",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Property",
  "symbol" : {
    "kind" : "Instance Property",
    "modules" : [
      "Device Activity"
    ],
    "preciseIdentifier" : "s:14DeviceActivity0aB4DataV0B7SegmentV07longestB010Foundation12DateIntervalVSgvp"
  },
  "title" : "longestActivity"
}
-->

# longestActivity

Access the date interval of the longest activity session during the activity segment.

```
var longestActivity: DateInterval?
```

## Discussion

This value may be `nil` if the person didn’t use this device during [`dateInterval`](/documentation/DeviceActivity/DeviceActivityData/ActivitySegment/dateInterval).

---

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)