YouTip LogoYouTip

iOS Tutorial - Getting Started

Swift for iOS

class ViewController: UIViewController {
    override func viewDidLoad() {
        super.viewDidLoad()
        let label = UILabel()
        label.text = "Hello, iOS!"
        view.addSubview(label)
    }
}

Swift Basics

let name = "Alice"       // constant
var age = 25             // variable
var email: String? = nil // optional

if let e = email {
    print(e)
}

Summary

  • Swift uses let for constants, var for variables
  • Optionals handle nil safely
← Flutter Tutorial - Getting StaAndroid Tutorial - Getting Sta β†’