---
title: "associate(to:password:)"
framework: corewlan
role: symbol
role_heading: Instance Method
path: "corewlan/cwinterface/associate(to:password:)"
---

# associate(to:password:)

Associates to a given network using the given network passphrase.

## Declaration

```swift
func associate(to network: CWNetwork, password: String?) throws
```

## Parameters

- `network`: The network to which the interface will associate.
- `password`: The network passphrase or key. Required for association to WEP, WPA Personal, and WPA2 Personal networks.

## Discussion

Discussion This method will block for the duration of the association. This operation may require an administrator password. note: In Swift, this method returns Void and is marked with the throws keyword to indicate that it throws an error in cases of failure. You call this method in a try expression and handle any errors in the catch clauses of a do statement, as described in Error Handling in The Swift Programming Language and About Imported Cocoa Error Parameters.

## See Also

### Associating to a network

- [associate(toEnterpriseNetwork:identity:username:password:)](corewlan/cwinterface/associate(toenterprisenetwork:identity:username:password:).md)
