---
title: "init(format:locale:arguments:)"
framework: foundation
role: symbol
role_heading: Initializer
path: "foundation/nsstring/init(format:locale:arguments:)"
---

# init(format:locale:arguments:)

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 information. This method is meant to be called from within a variadic function, where the argument list will be available.

## Declaration

```swift
convenience init(format: String, locale: Any?, arguments argList: CVaListPointer)
```

## 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 (specified by user preferences), pass [doc://com.apple.foundation/documentation/Foundation/NSLocale doc://com.apple.foundation/documentation/Foundation/NSLocale/current]. To use the system locale, pass nil. For legacy support, this may be an instance of NSDictionary containing locale information.
- `argList`: A list of arguments to substitute into format.

## Return Value

Return Value An NSString object initialized by using format as a template into which values in argList are substituted according the locale information in locale. The returned object may be different from the original receiver.

## Discussion

Discussion The following Objective-C code fragment illustrates how to create a string from myArgs, which is derived from a string object with the value “Cost:” and an int with the value 32: va_list myArgs;   NSString *myString = [[NSString alloc] initWithFormat:@"%@: %d\n"                                                locale:[NSLocale currentLocale]                                             arguments:myArgs]; The resulting string has the value “Cost: 32\n”. See String Programming Guide for more information.

## See Also

### Creating and Initializing Strings

- [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)
- [init(format:arguments:)](foundation/nsstring/init(format:arguments:).md)
- [init(data:encoding:)](foundation/nsstring/init(data:encoding:).md)
- [localizedUserNotificationString(forKey:arguments:)](foundation/nsstring/localizedusernotificationstring(forkey:arguments:).md)
- [localizedStringWithFormat(_:_:)](foundation/nsstring/localizedstringwithformat(_:_:).md)
- [unichar](foundation/unichar.md)
