---
title: "localizedStringWithFormat:"
framework: foundation
role: symbol
role_heading: Type Method
path: "foundation/nsstring/localizedstringwithformat:"
---

# localizedStringWithFormat:

Returns a string created by using a given format string as a template into which the remaining argument values are substituted according to the current locale.

## Declaration

```occ
+ (instancetype) localizedStringWithFormat:(NSString *) format;
```

## 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. Raises an NSInvalidArgumentException if format is nil.

## Return Value

Return Value A string created by using format as a template into which the following argument values are substituted according to the formatting information in the current locale.

## Discussion

Discussion Pass a comma-separated list of variadic arguments to substitute into format. This method is equivalent to using initWithFormat:locale: and passing the current locale as the locale argument. As an example of formatting, this method replaces the decimal according to the locale in %f and %d substitutions, and calls description(withLocale:) instead of description() where necessary. This code excerpt creates a string from another string and a float: NSString *myString = [NSString localizedStringWithFormat:@"%@:  %f\n", @"Cost", 1234.56]; The resulting string has the value “Cost: 1234.560000\n” if the locale is en_US, and “Cost: 1234,560000\n” if the locale is fr_FR. See Formatting String Objects for more information.

## 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)
- [initWithFormat:locale:](foundation/nsstring/initwithformat:locale:.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)
- [localizedUserNotificationString(forKey:arguments:)](foundation/nsstring/localizedusernotificationstring(forkey:arguments:).md)
- [stringWithCharacters:length:](foundation/nsstring/stringwithcharacters:length:.md)
