<!--
{
  "availability" : [
    "macOS: 10.5.0 - 10.11.0"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSAttributedString/url(at:effectiveRange:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSAttributedString(im)URLAtIndex:effectiveRange:"
  },
  "title" : "url(at:effectiveRange:)"
}
-->

# url(at:effectiveRange:)

Returns a URL, either from a link attribute or from text at the specified location that appears to be a URL string, for use in automatic link detection.

```
func url(at location: Int, effectiveRange: NSRangePointer) -> URL?
```

## Parameters

`location`

The character index in the string at which the method checks for a link.

`effectiveRange`

The actual range covered by the link attribute or URL string, or of non-URL text if no apparent URL is found.

## Return Value

The URL found at `location`.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)