iOS Development

ios – Is there a bonus to hiding the mannequin layer?

I used to be taking a look at a tutorial on the MVVM structure sample.

It says that views ought to by no means have direct entry to the mannequin. So all views are all the time hidden behind a view mannequin.

For instance:


struct Location: Codable, Equatable {

//MARK: Properties

let id: String
let title: String
let nation: String

let latitude: Double
let longitude: Double

init(id: String, title: String, nation: String, latitude: Double, longitude: Double) { = id
    self.title = title
    self.nation = nation
    self.latitude = latitude
    self.longitude = longitude

View Mannequin that conceal the mannequin layer

closing class LocationCellViewModel: Identifiable {

//MARK: Properties

non-public let location: Location

var locationViewModel: LocationViewModel {
    .init(location: location)

// MARK: - Initialization

init(location: Location) {
    self.location = location

// MARK: - Public API

var locationName: String {

var locationCountry: String {



View Mannequin that might be within the view as property

closing class LocationsViewModel {

//MARK: Properties

non-public(set) var locationCellViewModels: [LocationCellViewModel] = []



Why would possibly or not it’s higher to have a LocationCellViewModel array as an alternative of a Location array within the LocationsViewModel class? Is there any benefit to doing so?


Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button