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

# initWithFormat:locale:

Returns an NSString object initialized by using a given format string as a template into which the remaining argument values are substituted according to given locale.

## Declaration

```occ
- (instancetype) initWithFormat:(NSString *) format locale:(id) locale;
```

## Parameters

- `format`: A format string. See https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/Strings/Articles/FormatStrings.html#//apple_ref/doc/uid/20000943 for examples of how to use this method, and https://developer.apple.com/library/archive/documentation/CoreFoundation/Conceptual/CFStrings/formatSpecifiers.html#//apple_ref/doc/uid/TP40004265 for a list of format specifiers. This value must not be nil. important: Raises an NSInvalidArgumentException if format is nil.
- `locale`: An doc://com.apple.foundation/documentation/Foundation/NSLocale object specifying the locale to use. To use the current locale, pass [NSLocale currentLocale]. To use the system locale, pass nil. For legacy support, this may be an instance of NSDictionary containing locale information.

## Discussion

Discussion Pass comma-separated list of trailing variadic arguments to substitute into format. Invokes init(format:locale:arguments:) with locale as the locale.

## See Also

### Creating and Initializing Strings

- [string](foundation/nsstring/string.md)
- [init()](foundation/nsstring/init().md)
- [init(bytes:length:encoding:)](foundation/nsstring/init(bytes:length:encoding:).md)
- [init(bytesNoCopy:length:encoding:freeWhenDone:)](foundation/nsstring/init(bytesnocopy:length:encoding:freewhendone:).md)
- [init(characters:length:)](foundation/nsstring/init(characters:length:).md)
- [init(charactersNoCopy:length:freeWhenDone:)](foundation/nsstring/init(charactersnocopy:length:freewhendone:).md)
- [init(string:)](foundation/nsstring/init(string:)-210xa.md)
- [initWithFormat:](foundation/nsstring/initwithformat:.md)
- [init(format:arguments:)](foundation/nsstring/init(format:arguments:).md)
- [init(format:locale:arguments:)](foundation/nsstring/init(format:locale:arguments:).md)
- [init(data:encoding:)](foundation/nsstring/init(data:encoding:).md)
- [stringWithFormat:](foundation/nsstring/stringwithformat:.md)
- [localizedStringWithFormat:](foundation/nsstring/localizedstringwithformat:.md)
- [localizedUserNotificationString(forKey:arguments:)](foundation/nsstring/localizedusernotificationstring(forkey:arguments:).md)
- [stringWithCharacters:length:](foundation/nsstring/stringwithcharacters:length:.md)
