---
title: "init(request:delegate:startImmediately:)"
framework: foundation
role: symbol
role_heading: Initializer
path: "foundation/nsurlconnection/init(request:delegate:startimmediately:)"
---

# init(request:delegate:startImmediately:)

Returns an initialized URL connection and begins to load the data for the URL request, if specified.

## Declaration

```swift
init?(request: URLRequest, delegate: Any?, startImmediately: Bool)
```

## Parameters

- `request`: The URL request to load. The request object is deep-copied as part of the initialization process. Changes made to request after this method returns do not affect the request that is used for the loading process.
- `delegate`: The delegate object for the connection. The connection calls methods on this delegate as the load progresses.
- `startImmediately`: doc://com.apple.documentation/documentation/Swift/true if the connection should begin loading data immediately, otherwise doc://com.apple.documentation/documentation/Swift/false. If you pass doc://com.apple.documentation/documentation/Swift/false, the connection is not scheduled with a run loop. You can then schedule the connection in the run loop and mode of your choice by calling doc://com.apple.foundation/documentation/Foundation/NSURLConnection/schedule(in:forMode:).

## Return Value

Return Value The URL connection for the URL request. Returns nil if a connection can’t be initialized.

## Discussion

Discussion During the download the connection maintains a strong reference to the delegate. It releases that strong reference when the connection finishes loading, fails, or is canceled.

## See Also

### Loading Data Asynchronously

- [init(request:delegate:)](foundation/nsurlconnection/init(request:delegate:).md)
- [sendAsynchronousRequest(_:queue:completionHandler:)](foundation/nsurlconnection/sendasynchronousrequest(_:queue:completionhandler:).md)
- [start()](foundation/nsurlconnection/start().md)
