jarvisbox

Objective-C @property to Swift var/let

Objective-C uses @property declarations in the @interface section to define class properties. Swift uses stored properties (var and let) declared directly in the class body. The mapping between the two is mechanical but tedious to do by hand across large codebases.

The converter applies these rules automatically:

• @property (strong, nonatomic) NSString *name → var name: String • @property (nonatomic, readonly) NSString *title → let title: String • @property (nonatomic, weak) id<UIDelegate> delegate → weak var delegate: UIDelegate? • @property (nonatomic, assign) NSInteger count → var count: Int • @property (nonatomic, copy) NSString *text → var text: String

The Swift storage keywords var (mutable) and let (immutable) map from the readonly attribute: a readonly property becomes let; all others become var. The weak attribute maps to Swift's weak modifier with an implicit optional (?). NS* types are replaced with their Swift equivalents.

Paste your entire .h or .m file — the converter processes every @property declaration while preserving the surrounding code.

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

回報這個工具的問題