Swift: How to Migrate MVC to MVVM & Intro Unit Testing

Lets Build That App · 117K views · 2018 · 33:11

Open on YouTube

Software architecture & designTesting, debugging & developer toolstutorialdated

Why Stack Overflow recommends it

Stack Overflow users link it as a worked example of MVVM in iOS, especially when asking where view logic, table view cells and view models belong.

Recommended by 0 people across 0 different months, 2018 to 2018.

What it is

A 33-minute Swift tutorial from the Lets Build That App channel that takes an existing MVC iOS project and refactors it to MVVM. It finishes with a short introduction to writing unit tests to catch failures in the code.

What people said

Cites Róbert Oravec · 2018-07 · Stack Overflow · on “swift tableView in custom view programatically - losing reference to controllers delegate and data source”

Thanks for explanation. Maybe I will try different approach then, because I am not experienced enough to use something like RxSwift and RxCocoa for biding. In one tutorial I saw that viewModel was basicly just mapped struct from model to set up view in cell, and controller was downloading data, link to video: [ [this video] ] . What do you think of this approuch to MVVM, I am still learning, so I really don't know, where to put which logic.

Cites Bilal Mustafa · 2018-08 · Stack Overflow · on “For MVVM design pattern, where does table view cell height belong to?”

If you want the pure MVVM implementation put it in the view layer because cell height belongs to the how the cell should display and it is a pure view logic, but it is acceptable to some extent you can put some view related code in the ViewModel. To learn more about MVVM checkout this link about MVVM [this video]

Cites MJQZ1347 · 2018-11 · Stack Overflow · on “MVC: Is a custom UITableViewCell a view or controller or both?”

I used to consider a CustomUITableViewCell.xib as the view and the corresponding CustomUITableViewCell.swift class as the controller of a table view cell. Is this correct? A youtube video I stumbled upon considers the class as the view: [this video] Edit: To clarify the question: Which one of the following is the view and controller? Are both considered the view? CustomUITableViewCell.xib CustomUITableViewCell.swift