jarvisbox

Convert NSString to Swift String

NSString is the Objective-C Foundation class for immutable strings. In Swift, the equivalent is the built-in String value type, which is lighter-weight, thread-safe by default, and interoperable with NSString via automatic bridging.

The mechanical differences are significant: ObjC string literals are prefixed with @ (@"hello"), NSLog uses printf-style format strings, and NSString method calls use square-bracket message syntax ([NSString stringWithFormat:@"Hello %@", name]).

In Swift, all of these become idiomatic: string literals are plain "hello", print() handles logging, and string interpolation replaces format strings ("Hello \(name)"). The converter handles all these transformations automatically:

• @"string literal" → "string literal" • NSString *name = … → var name: String = … • [NSString stringWithFormat:fmt, args] → String(format: fmt, args) • NSLog(@"msg %@", val) → print(String(format: "msg %@", val))

This tool converts entire Objective-C files, not just individual lines. Paste your .h or .m file and get Swift output with a single click.

Open Objective-C to Swift Converter →

How to use

  1. Paste your Objective-C .m or .h code into the input panel on the converter page.
  2. Click Convert to Swift — the conversion runs instantly in your browser with no data leaving your device.
  3. Click Copy to copy the Swift 5.9 output, then paste it into Xcode and review any // TODO: comments.

Related tools

反馈这个工具的问题