Explore Library
Code QuizAdvanced

ViewModel Breaks Separation of Concerns

Spot the layering violation where the ViewModel reaches into the UI layer.

Codeswift
import UIKit

final class ProfileViewModel {
    private let service: UserService
    var nameLabel = UILabel()

    init(service: UserService) {
        self.service = service
    }

    func loadUser() {
        service.fetchUser { [weak self] user in
            self?.nameLabel.text = user.name
        }
    }
}

What is the architectural bug that breaks separation of concerns?