---
title: "scanForNetworks(withName:)"
framework: corewlan
role: symbol
role_heading: Instance Method
path: "corewlan/cwinterface/scanfornetworks(withname:)"
---

# scanForNetworks(withName:)

Scans for networks.

## Declaration

```swift
func scanForNetworks(withName networkName: String?) throws -> Set<CWNetwork>
```

## Parameters

- `networkName`: The name (SSID) of the network for which to scan.

## Return Value

Return Value A set of CWNetwork objects.

## Discussion

Discussion If ssid parameter is present, a directed scan will be performed by the interface, otherwise a broadcast scan will be performed. This method will block for the duration of the scan. note: In Swift, this method returns a nonoptional result 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

### Scanning for networks

- [scanForNetworks(withSSID:)](corewlan/cwinterface/scanfornetworks(withssid:).md)
