Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS Implementing MVVM

Filipe Alvarenga
Filipe Alvarenga
5,478 Points

Networking calls still in the controller

In the beginning of the video Amit said that networking calls shouldn't be made from the controller. Until the end of the video it was still there, but Amit ended it saying that the controller was compliant to MVVM. I found it confusing.

1 Answer

Jhoan Arango
Jhoan Arango
14,575 Points

Hello,

Amit was mostly showing an example of how to do the MVVM, and he did suggest that networking call logic shouldn't be placed in the controller. He did not actually did this himself, but hinted as to implement this yourself if you ever run into this scenario.

One thing you can do is create a different file where all the networking calls are made out of and pass the results somewhere else. The controller can invoke a call and receive an answer, but it should not handle all the logics of it.