Objective-C Class to Swift Class
Objective-C splits every class across two files: a header (.h) containing the @interface declaration and an implementation (.m) containing the @implementation. Swift uses a single source file with the class body containing both the property declarations and method implementations.
The structural mapping is:
``` // Objective-C (.h) @interface Foo : NSObject <SomeProtocol> @property (strong, nonatomic) NSString *name; - (void)doSomething; @end
// Objective-C (.m) @implementation Foo - (void)doSomething { /* body */ } @end ```
becomes:
``` // Swift class Foo: NSObject, SomeProtocol { var name: String func doSomething() { /* body */ } } ```
This converter handles class hierarchies, protocol conformances (the <Proto1, Proto2> list in Objective-C becomes , Proto1, Proto2 after the superclass in Swift), categories (@interface Foo (CategoryName) → extension Foo), and anonymous extensions (@interface Foo ()). Paste your .h and .m contents together and get a merged Swift class.
How to use
- Paste your Objective-C
.mor.hcode into the input panel on the converter page. - Click Convert to Swift — the conversion runs instantly in your browser with no data leaving your device.
- Click Copy to copy the Swift 5.9 output, then paste it into Xcode and review any
// TODO:comments.