---
title: AttributedStringProtocol
framework: foundation
role: symbol
role_heading: Protocol
path: foundation/attributedstringprotocol
---

# AttributedStringProtocol

A protocol that provides common functionality to attributed strings and attributed substrings.

## Declaration

```swift
@dynamicMemberLookup protocol AttributedStringProtocol : AttributedStringAttributeMutation, CustomStringConvertible, Hashable, Sendable
```

## Overview

Overview Don’t declare new conformances to AttributedStringProtocol. Only the AttributedString and AttributedSubstring types in the standard library are valid conforming types.

## Topics

### Applying Attributes

- [settingAttributes(_:)](foundation/attributedstringprotocol/settingattributes(_:).md)
- [mergingAttributes(_:mergePolicy:)](foundation/attributedstringprotocol/mergingattributes(_:mergepolicy:).md)
- [AttributedString.AttributeMergePolicy](foundation/attributedstring/attributemergepolicy.md)
- [replacingAttributes(_:with:)](foundation/attributedstringprotocol/replacingattributes(_:with:).md)

### Searching for a Substring

- [range(of:options:locale:)](foundation/attributedstringprotocol/range(of:options:locale:).md)

### Accessing a Range

- [subscript(_:)](foundation/attributedstringprotocol/subscript(_:)-109me.md)

### Accessing Indices

- [startIndex](foundation/attributedstringprotocol/startindex.md)
- [endIndex](foundation/attributedstringprotocol/endindex.md)
- [index(_:offsetByCharacters:)](foundation/attributedstringprotocol/index(_:offsetbycharacters:).md)
- [index(_:offsetByRuns:)](foundation/attributedstringprotocol/index(_:offsetbyruns:).md)
- [index(_:offsetByUnicodeScalars:)](foundation/attributedstringprotocol/index(_:offsetbyunicodescalars:).md)
- [index(afterCharacter:)](foundation/attributedstringprotocol/index(aftercharacter:).md)
- [index(afterRun:)](foundation/attributedstringprotocol/index(afterrun:).md)
- [index(afterUnicodeScalar:)](foundation/attributedstringprotocol/index(afterunicodescalar:).md)
- [index(beforeCharacter:)](foundation/attributedstringprotocol/index(beforecharacter:).md)
- [index(beforeRun:)](foundation/attributedstringprotocol/index(beforerun:).md)
- [index(beforeUnicodeScalar:)](foundation/attributedstringprotocol/index(beforeunicodescalar:).md)
- [AttributedString.Index](foundation/attributedstring/index.md)

### Accessing Views into the Attributed String

- [characters](foundation/attributedstringprotocol/characters.md)
- [unicodeScalars](foundation/attributedstringprotocol/unicodescalars.md)
- [runs](foundation/attributedstringprotocol/runs.md)

### Accessing Whole-String Attributes

- [subscript(_:)](foundation/attributedstringprotocol/subscript(_:)-4thnp.md)
- [subscript(dynamicMember:)](foundation/attributedstringprotocol/subscript(dynamicmember:)-2wake.md)
- [AttributeDynamicLookup](foundation/attributedynamiclookup.md)
- [subscript(dynamicMember:)](foundation/attributedstringprotocol/subscript(dynamicmember:)-55pcu.md)
- [ScopedAttributeContainer](foundation/scopedattributecontainer.md)

### Comparing Attributed Strings or Substrings

- [==(_:_:)](foundation/attributedstringprotocol/==(_:_:).md)

### Instance Properties

- [utf16](foundation/attributedstringprotocol/utf16.md)
- [utf8](foundation/attributedstringprotocol/utf8.md)

### Default Implementations

- [CustomStringConvertible Implementations](foundation/attributedstringprotocol/customstringconvertible-implementations.md)
- [Hashable Implementations](foundation/attributedstringprotocol/hashable-implementations.md)

## Relationships

### Inherits From

- [AttributedStringAttributeMutation](foundation/attributedstringattributemutation.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [Sendable](swift/sendable.md)
- [SendableMetatype](swift/sendablemetatype.md)

### Conforming Types

- [AttributedString](foundation/attributedstring.md)
- [AttributedSubstring](foundation/attributedsubstring.md)
