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-CSwiftConsideration
NSString *StringA Swift value type
NSInteger / NSUIntegerInt / UIntUse unsigned values only when your domain requires them
BOOL / YES / NOBool / true / falseA distinct Boolean type
NSArray<T> *[T]Choose an explicit element type
NSDictionary<K, V> *[K: V]Keys must conform to Hashable
nullableOptional<T> / T?Represent actual absence
NSError **throwsUpdate caller error handling
completion blockasync / awaitReview 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