The M in MVC

The ideas behind MVC are pretty straight forward. You call a database. The Data is returned as JSON formatted text. The JSON is parsed, and fed into your Custom UITableViewCell. That's the bread and butter of most Apps. Data structures are represented as a Model.

Lets build a Model. Our App will display a list of concerts. Models can of course be very complicated, this is simple one for illustrative purposes. What makes up a concert event?

A concert has a name [Winter Blast], location [Barclays Arena], description [EDM concert with 12 bands], date [1/1/2015], and an image of that awesome flyer [flyer.png].

          import Foundation

          class Concert {
              var name = String()
              var location = String()
              var description = String()
              var date = String()
              var image = String()

              init(name:String, location:String, description:String, date:String, image:String) {
                  self.name = name
                  self.location = location
                  self.description = description
                  self.date = date
                  self.image = image
              }
            }
          

And lets break this out, line by line.

import Foundation

Direct from Apple docs:
This import makes all of the Foundation APIs—including NSDate, NSURL, NSMutableData, and all of their methods, properties, and categories—directly available in Swift.