what comes in "Model" "View" "Controller" for UITableView ?

New to iOS.when it comes to populating data from web service to uitableview/uicollectionview. what should i include in MVC. i mean what should i put in "Model","View" & "Controller" ?


Example: if i have to populate data into uitableview using afnetworking/ nsurlsession. what is the MVC pattern for it ?

Replies

View describes how things are displayed ; it gets its data from the model, calling method that provide the content. If you have a textField giving a totalValue of other fields, you should call the method "totalOfFields" defined in the model


Model describes the data structure and the computations about it.


Controller is the business logic, defining actions ; it may ask to update display, but do not do it itself.


There was a great introduction to MVC in Stanford course for IOS on the matter (look at lesson 2):

h ttps://itunes.apple.com/us/course/developing-ios-9-apps-swift/id1104579961

Typically, the model contains "pure" data that doesn't "know" what UI is going to be used to display or access it. If you're downloading some information, the model usually contains the downloaded data, or (in the case where you don't download all the data at once) the model is a local wrapper for the remote data.


Have you looked at Apple's documentation on MVC, for example:


https://developer.apple.com/library/content/documentation/General/Conceptual/CocoaEncyclopedia/Model-View-Controller/Model-View-Controller.html


If you haven't the extended discussion may clarify some things for you.

What Claude31 and QuinceyMorris have already said plus…

With regards networking, you might want to check out this post, where I explain how I handle networking in my apps.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"