Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where does the AppDelegate file fit into MVC?

I'm learning iPhone/iPad programming. I believe I understand the concept of MVC; what I'm having difficulty with is understanding how some of the files in a normal iPhone/iPad application fit into MVC.

When you create a new application using the "View-Based Application" template an AppDelegate.m and AppDelegate.h file is created.

Is that a Model, View, or Controller file? I'm guessing it's actually none of those. I wish I could see a diagram or a process flowchart that shows what category each file in the application falls into.

like image 886
Matthew Walk Avatar asked Nov 03 '11 16:11

Matthew Walk


2 Answers

Not every file will fit a particular category, however, I would have to say in this instance the AppDelegate is a controller, it doesn't visually present data (a view) nor does it represent the actual data (a model) but it does determine what view controllers to show etc and manage other views (status bar etc) at the start of the application.

I wouldn't worry too much about trying to classify every file into MVC, some just won't fit perfectly, if at all.

like image 135
Simon Lee Avatar answered Oct 06 '22 14:10

Simon Lee


The application delegate is a controller object. By default, it is the owner and controller of the main window -- which is a view -- in an iOS app. The app delegate receives messages from an object representing -- or modeling -- the application itself (an instance of UIApplication). It mediates between the application object, which is the contact point between the app and the system, and the display of the app.

like image 28
jscs Avatar answered Oct 06 '22 12:10

jscs