Xamarin.iOS – Intro to UIViewController

In this lesson

  • Brief introduction to Model-View-Controller architecture
  • Cover generated methods ViewDidLoad and DidReceiveMemoryWarning

Transcript

Tap on time to skip ahead

00:00

ViewController is in iOS all of your views, for the most part, have a UIViewController. ViewController comes from object oriented programing concept of Model View Controller. It’s a framework. It’s also called MVC. Basically, you can think of a view controller as a puppet master for your view. It’s responsible for interacting with buttons or text fields, and then interacting with models or web services. It acts as the glue between your data and your view.

00:37

This is again, another file that is generated by Xamarin Studio. You can see we have two methods that have already been overwritten for us. ViewDidLoad, as the Xamarin Studio comments says, “perform any additional setup after loading the view, typically from a nib.” Then, we also have this method here, DidReceiveMemoryWarning. What this is-I’ve been fortunate to not have to do too much with this-but let’s say your application is doing a lot of stuff with images and chewing up a lot of memory. iOS will say, “Hey, your application is kind of being a resource hog. I’m giving you a warning.” If you ignore this warning and don’t release any of that memory or clean up after yourself, at some point iOS is going to at flat out kill your application. This is a feature of iOS to make sure that apps don’t go rogue, that they don’t corrupt the iOS experience.