FROM FAMILIAR PATTERNS TO SWIFT
Objective-C to Swift
A small migration helper for common declarations, simple properties, and logging. Unsupported lines are marked for manual review. Translation stays in your browser.
Objective-C
Swift draft
import Foundation
var name: String = "Sam"
var count: Int = 3
var ready: Bool = true
print(name)4 lines translated
Common equivalents
Migration involves design decisions as well as syntax. Use this table as a starting point.
| Objective-C | Swift | Consideration |
|---|---|---|
NSString * | String | A Swift value type |
NSInteger / NSUInteger | Int / UInt | Use unsigned values only when your domain requires them |
BOOL / YES / NO | Bool / true / false | A distinct Boolean type |
NSArray<T> * | [T] | Choose an explicit element type |
NSDictionary<K, V> * | [K: V] | Keys must conform to Hashable |
nullable | Optional<T> / T? | Represent actual absence |
NSError ** | throws | Update caller error handling |
completion block | async / await | Review cancellation and actor isolation |
The helper handles literal scalar declarations and a limited set of property and NSLog patterns. It does not parse complete classes or guarantee equivalent behavior. Validate migrated code in your project.
Appleās Objective-C migration guide