ADVERTISEMENT
Google AdSense Slot (headerLeaderboard)

Set your Publisher ID in src/config/ads.ts to display live ads.

Swift Tutorial• 6 min read

Swift Introduction & The Apple Ecosystem

Fast, modern, type-safe language designed by Apple for native apps

Introduced by Apple in 2014 to replace Objective-C, Swift is a powerful, open-source, compiled language designed for maximum performance, safety, and developer ergonomics.

Key Features of Swift

let (Constant) vs var (Variable): Swift strongly encourages immutability (let) by default to prevent unexpected side effects.

Type Inference: You rarely need to write explicit types; Swift infers types automatically from initial values.

String Interpolation: Embed expressions inside strings using \(expression).

First Swift Program
// let creates an immutable constant; var creates a mutable variable
let appTitle = "Codexia iOS Mastery"
var studentCount = 3500

// String interpolation with \()
print("Welcome to \(appTitle)! Enrolled students: \(studentCount)")

studentCount += 1
print("New student enrolled. Total: \(studentCount)")
let enforces immutability; \() performs string interpolation.
ADVERTISEMENT
Google AdSense Slot (inContentBanner)

Set your Publisher ID in src/config/ads.ts to display live ads.

Test Yourself With Exercise

+15 XP

Which keyword in Swift is used to declare an immutable constant whose value cannot change after initialization?