---
title: "CFNetDiagnosticCreateWithURL(_:_:)"
framework: cfnetwork
role: symbol
role_heading: Function
path: "cfnetwork/cfnetdiagnosticcreatewithurl(_:_:)"
---

# CFNetDiagnosticCreateWithURL(_:_:)

Creates a CFNetDiagnosticRef from a CFURLRef.

## Declaration

```swift
func CFNetDiagnosticCreateWithURL(_ alloc: CFAllocator, _ url: CFURL) -> Unmanaged<CFNetDiagnostic>
```

## Parameters

- `alloc`: The allocator to use to allocate memory for the new object. Pass NULL or kCFAllocatorDefault to use the current default allocator.
- `url`: CFURLRef that refers to the failed connection.

## Return Value

Return Value CFNetDiagnosticRef that you can pass to CFNetDiagnosticDiagnoseProblemInteractively(_:) or CFNetDiagnosticCopyNetworkStatusPassively(_:_:). Ownership follows the The Create Rule.

## Discussion

Discussion This function uses a URL to create a reference to an instance of a CFNetDiagnostic object. You can pass the reference to CFNetDiagnosticDiagnoseProblemInteractively(_:) to open a Network Diagnostics window or to CFNetDiagnosticCopyNetworkStatusPassively(_:_:) to get a description of the connection referenced by readStream and writeStream. Special Considerations This function is thread safe as long as another thread does not alter the same CFNetDiagnosticRef at the same time.

## See Also

### Network Diagnostics

- [CFNetDiagnostic](cfnetwork/cfnetdiagnostic.md)
- [CFNetDiagnosticStatusValues](cfnetwork/cfnetdiagnosticstatusvalues.md)
- [CFNetDiagnosticCopyNetworkStatusPassively(_:_:)](cfnetwork/cfnetdiagnosticcopynetworkstatuspassively(_:_:).md)
- [CFNetDiagnosticCreateWithStreams(_:_:_:)](cfnetwork/cfnetdiagnosticcreatewithstreams(_:_:_:).md)
- [CFNetDiagnosticDiagnoseProblemInteractively(_:)](cfnetwork/cfnetdiagnosticdiagnoseprobleminteractively(_:).md)
- [CFNetDiagnosticSetName(_:_:)](cfnetwork/cfnetdiagnosticsetname(_:_:).md)
