---
title: "initWithFormat:options:locale:context:"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/nsattributedstring/initwithformat:options:locale:context:"
---

# initWithFormat:options:locale:context:

Initializes an attributed string by substituting arguments into a specially formatted string and applying additional contextual information.

## Declaration

```occ
- (instancetype) initWithFormat:(NSAttributedString *) format options:(NSAttributedStringFormattingOptions) options locale:(NSLocale *) locale context:(NSDictionary<NSString *,id> *) context;
```

## Parameters

- `format`: The format string to use to create the final string. For a list of format specifiers you can include in this string, see https://developer.apple.com/library/archive/documentation/CoreFoundation/Conceptual/CFStrings/formatSpecifiers.html#//apple_ref/doc/uid/TP40004265.
- `options`: Options for how to apply attributes to the string’s content.
- `locale`: The locale to use for formatting the string. The locale controls the formatting of region-sensitive values such as numbers and currencies.
- `context`: Additional options to apply to the string.

## Return Value

Return Value An initialized attributed string that combines the format string with the provided arguments and other information.

## Discussion

Discussion Pass an optional list of trailing variadic arguments to substitute into the format string.

## See Also

### Creating a formatted string

- [initWithFormat:options:locale:](foundation/nsattributedstring/initwithformat:options:locale:.md)
- [initWithFormat:options:locale:arguments:](foundation/nsattributedstring/initwithformat:options:locale:arguments:.md)
- [initWithFormat:options:locale:context:arguments:](foundation/nsattributedstring/initwithformat:options:locale:context:arguments:.md)
- [localizedAttributedStringWithFormat:](foundation/nsattributedstring/localizedattributedstringwithformat:.md)
- [localizedAttributedStringWithFormat:options:](foundation/nsattributedstring/localizedattributedstringwithformat:options:.md)
- [localizedAttributedStringWithFormat:context:](foundation/nsattributedstring/localizedattributedstringwithformat:context:.md)
- [localizedAttributedStringWithFormat:options:context:](foundation/nsattributedstring/localizedattributedstringwithformat:options:context:.md)
- [NSAttributedStringFormattingOptions](foundation/nsattributedstringformattingoptions.md)
