<!--
{
  "availability" : [
    "iOS: 2.0.0 -",
    "iPadOS: 2.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.0.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSString/localizedStringWithFormat:",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSString(cm)localizedStringWithFormat:"
  },
  "title" : "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.

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

## Parameters

`format`

A format string. See [Formatting String Objects](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 [String Format Specifiers](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

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

Pass a comma-separated list of variadic arguments to substitute into `format`.

This method is equivalent to using [`initWithFormat:locale:`](/documentation/Foundation/NSString/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:)`](/documentation/Foundation/NSNumber/description(withLocale:)) instead of <doc://com.apple.documentation/documentation/ObjectiveC/NSObject-swift.class/description()> where necessary.

This code excerpt creates a string from another string and a float:

```objc
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](https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/Strings/Articles/FormatStrings.html#//apple_ref/doc/uid/20000943) for more information.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)