---
title: "CFAttributedStringCreateWithSubstring(_:_:_:)"
framework: corefoundation
role: symbol
role_heading: Function
path: "corefoundation/cfattributedstringcreatewithsubstring(_:_:_:)"
---

# CFAttributedStringCreateWithSubstring(_:_:_:)

Creates a sub-attributed string from the specified range.

## Declaration

```swift
func CFAttributedStringCreateWithSubstring(_ alloc: CFAllocator!, _ aStr: CFAttributedString!, _ range: CFRange) -> CFAttributedString!
```

## Parameters

- `alloc`: The allocator to use to allocate memory for the new attributed string. Pass NULL or doc://com.apple.corefoundation/documentation/CoreFoundation/kCFAllocatorDefault to use the current default allocator.
- `aStr`: The attributed string to copy.
- `range`: The range of the attributed string to copy. range must not exceed the bounds of aStr.

## Return Value

Return Value A new attributed string whose string and attributes are copied from the specified range of the supplied attributed string. Returns NULL if there was a problem copying the object. Ownership follows the The Create Rule.

## See Also

### Creating a CFAttributedString

- [CFAttributedStringCreate(_:_:_:)](corefoundation/cfattributedstringcreate(_:_:_:).md)
- [CFAttributedStringCreateCopy(_:_:)](corefoundation/cfattributedstringcreatecopy(_:_:).md)
- [CFAttributedStringGetLength(_:)](corefoundation/cfattributedstringgetlength(_:).md)
- [CFAttributedStringGetString(_:)](corefoundation/cfattributedstringgetstring(_:).md)
