---
title: delegate
framework: foundation
role: symbol
role_heading: Instance Property
path: foundation/urlsession/delegate
---

# delegate

The delegate assigned when this object was created.

## Declaration

```swift
var delegate: (any URLSessionDelegate)? { get }
```

## Discussion

Discussion This delegate object is responsible for handling authentication challenges, for making caching decisions, and for handling other session-related events. The session object keeps a strong reference to this delegate until your app exits or explicitly invalidates the session. If you do not invalidate the session, your app leaks memory until it exits. note: This delegate object must be set at object creation time and may not be changed.

## See Also

### Working with a delegate

- [URLSessionDelegate](foundation/urlsessiondelegate.md)
- [URLSessionTaskDelegate](foundation/urlsessiontaskdelegate.md)
- [delegateQueue](foundation/urlsession/delegatequeue.md)
