From the course: iOS Development: Architecture

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Refactoring to MVP: View controller

Refactoring to MVP: View controller

From the course: iOS Development: Architecture

Start my 1-month free trial

Refactoring to MVP: View controller

- [Instructor] Instead of accessing the model directly, we moved the model to a dedicated model structure. Besides, we introduced a presenter of class to mediate between the view controller and the model. So, let's switch to the master view controller and start refactoring it. We can now safely delete the objects properly and use a presenter instance instead. Next comes the insert new object method. The view controller doesn't manipulate the model directly. Instead, it relies on the presenter, so let's remove this line. Instead, I'm going to call presenter add entry. Let's continue with the prepare for segueway sender method. We won't pass the date object to the detail view controller. The presenter can return the formatted daytime string so we're going to rather use that. So, I replace this line of code with a call to the presenter subscript. The only issue is that the detail view controller's detail item is of type NS date. So, let's fix this in the detail view controller, instead…

Contents