Should Xcode Include a Default Model for New Projects?

The MVC (Model View Controller) design pattern in iOS development is pretty standard. So standard that Apple not only recommends it, but the default initial files in a new Xcode project push you generally in that direction… for the most part.

I read this interesting article about refactoring MVC to MVVM, and the author talks about the way Apple only partially pushes MVC. From a new project:

You get your initial View in Main.storyboard
You get your Controller in ViewController.swift
You get your initial Model in… nowhere

The author suggests adding in a default file called Model.swift and giving it some base data:

struct Model {
    // Define properties representing your app's data here.

This is great, because it makes it so much clearer what everything is and should be doing in the MVC design pattern. When I was a beginner, I would’ve loved to see this every time I started a new project. To beginners, it’s the small things that matter and having a little extra guidance goes a long way.

And it’s not like Apple is slow to remove or add project defaults in newer versions of Xcode. Every View Controller used to come default with:

override func didReceiveMemoryWarning() {
    // Dispose of any resources that can be recreated

And taking part of AppDelegate.swift and turning it into the entirely new file SceneDelegate.swift is still pretty recent.


Maybe it’s too obvious. Maybe it is better to leave the programmer to just add it in so they get a better feel for it?

Leave a Comment

Your email address will not be published. Required fields are marked *