Browse Questions
  • A race condition occurs when two or more threads access shared mutable state simultaneously, producing unpredictable results depending on timing.
  • You can detect memory leaks automatically in unit tests by attaching an addTeardownBlock to XCTestCase with a weak reference to the system under test and asserting that the instance deallocates to…
  • async let starts a child task immediately and lets you await its result later.
  • Most candidates fail coding interviews not because they can't code, but because they lack a structured thinking process.

Answer: async let starts a child task immediately and lets you await its result later. It's the cleanest way to run a fixed number of async operations in parallel.

Code Example:

// Sequential — slow (waits for each one)
func loadDashboard() async throws -> Dashboard {
    let user = try await fetchUser()          // waits
    let posts = try await fetchPosts()        // then waits
    let notifications = try await fetchNotifications() // then waits
    return Dashboard(user: user, posts: posts, notifications: notifications)
}

// Parallel with async let — all three start at the same time
func loadDashboard() async throws -> Dashboard {
    async let user = fetchUser()
    async let posts = fetchPosts()
    async let notifications = fetchNotifications()

    return try await Dashboard(
        user: user,
        posts: posts,
        notifications: notifications
    )
}

Rule of thumb: Use async let for a fixed set of concurrent operations. Use TaskGroup for a dynamic number.