---
title: "canInit(with:)"
framework: foundation
role: symbol
role_heading: Type Method
path: "foundation/urlprotocol/caninit(with:)-18gbo"
---

# canInit(with:)

Determines whether the protocol subclass can handle the specified task.

## Declaration

```swift
class func canInit(with task: URLSessionTask) -> Bool
```

## Parameters

- `task`: A URL session task containing the request to be handled.

## Discussion

Discussion A subclass should inspect the task’s request and determine whether or not the implementation can perform a load with that task. This is an abstract method and subclasses must provide an implementation.

## See Also

### Determining If a subclass can handle a request

- [canInit(with:)](foundation/urlprotocol/caninit(with:)-76brg.md)
