[MUSIC] Let's take a look at the ViewController hierarchy in HoBshare, so that we understand who's responsible for controlling which parts of our UI. So, we're going to create one UIViewController subclass called HoBshareViewController. And HoBshareViewController Is going to conform to the CLLocationManagerDelegate, the UICollectionViewDelegate, the UICollectionViewDataSource, which is another protocol similar to these delegate methods, and also the UiCollectionViewDelegate flow layout, which helps us make sure that those buttons grow and shrink to take up the screen width appropriately. All right, so what does that mean? That means that HoBshareViewController, which in this diagram here is the superclass of our other three kind of actual on-screen ViewControllers, MeViewController, EditHobbiesViewController, and NeighborsViewController. Their superclass, HoBshareViewController, will control everything about how the CollectionView looks, where it gets its data from, how it resizes those cells at the bottom of the screen, etc. And it will also control everything, pretty much, about any location-related data or functions or callbacks with this CLLocationManager. All right, so let's take a look at how that's done. We have still inside of HoBshareViewController these properties. So one of them is an IBOutlet that points to the hobbiesCollectionView in our storyboard. We have a locationManager, which helps us do things like get our current location, make sure that we have permission to get our current location, and things like this. Stop getting our location. And so we have the locationManager property, and then we'll want to implement the required functions from the CLLocationManagerDelegate to do all that stuff. And so, all of that, all of those functions will be implemented inside of HoBshareViewController. Same thing with hobbiesCollectionView. So we'll have the protocol functions for this UICollectionViewDelegate and UICollectionViewDataSource implemented on HoBshareViewController. So that's all controlled in the superclass, which means that even though all three of our views, as you saw on the demo, all three of them have the collection view and also the MeViewController got my lat long, so it had to use my location, and the NeighborsViewController obviously gets my current position and puts it on the map, so I had to use the locationManager. We can use locationManager and the collection view in all of our subclasses, but only write all of that code one time in the superclass. All right, so then what do these three subclasses do? So here we have MeViewController, we override one location manger protocol to update the lat and long labels in our UI. And we, in our EditHobbiesViewController, we override a collectionView protocol, a collectionView delegate data source protocol. To determine what happens when we tap on one of the cells on the top to add a hobby, and tap on one of the cells at the bottom to delete a hobby. because we can only have three hobbies, so if we want to add another one, we first have to delete one of the ones from the bottom, right. Okay, so we put that custom functionality in the EditHobbiesViewController, not in the HoBshareViewController because we don't want everyone to be able to add or remove hobbies. Only when you're inside of the EditHobbiesViewController you should be able to edit or remove hobbies. And then likewise, in the NeighborsViewController, we override that collection view didSelectItem and index path. Same thing that we override in EditHobbiesViewController. We override that to say, when I tap on a hobby, show me users with that hobby on the map. So again, it wouldn't make sense to put that in the superclass. We'd do that only when we're in the NeighborsViewController scene, right. Because that's the only one with the map. And then, again, we override the location manager protocol to update the map with that little blue dot when our current location changes, because you in real life could be walking around or driving around with this application and you should see your location move. Or when you're working on this as a developer, you may simulate yourself into different locations, so you want to see your current location on the map change as well. And then, again, we need your current location on the map so that we can get your location and the location of other users all within one scope, so that you can see, where are people who share my hobby in relationship to me? [MUSIC]