Swift, SwiftUI/UIKit, concurrency, memory, app lifecycle
Practise these as flashcards. One or two lines each; the ones you miss come back first.
Start freeStructs are value types, so they are copied when assigned or passed. Classes are reference types, so variables refer to the same instance. Also, only classes support inheritance and deinitializers.
I use if let or guard let to safely unwrap optionals, which prevents runtime crashes from nil values. For example, if let name = user.name { print(name) }.
weak keyword do?weak creates a non-owning reference to an object, preventing retain cycles. It's commonly used for delegates or back-references in closures.
You declare conformance in the struct's definition, like struct Car: Drivable { ... }, and implement the protocol's required methods and properties.
TestFlight is Apple's beta testing platform. It lets you distribute pre-release versions of your app to testers before submitting to the App Store.
@State and @ObservedObject work in SwiftUI.@State is used for simple, local state owned by a view. @ObservedObject is for referencing an external, observable object that conforms to ObservableObject, allowing the view to react to its changes.
ARC automatically manages the memory of class instances by keeping track of strong references. When an instance's reference count drops to zero, it's deallocated. Retain cycles can prevent this, so we use weak or unowned to break them.
I use URLSession to make the request, then decode the response using Codable and JSONDecoder. For example, I create a model conforming to Codable and call JSONDecoder().decode(Model.self, from: data).
MainActor ensures that code runs on the main thread, which is required for UI updates. By annotating functions or classes with @MainActor, I guarantee thread safety for UI-related code.
For structured data, I use Core Data or SwiftData, which provide object graph management and persistence. For simpler needs, I might use UserDefaults or write Codable models to disk.
I use XCTest to write unit tests for the view model's logic. I inject dependencies, use mocks for services, and assert that the view model produces the expected outputs for given inputs.
I increment the version, archive the app in Xcode, upload it via Organizer, and submit it for review. I also use TestFlight for beta testing and ensure all assets and metadata are complete.