[MUSIC] There's one last thing that we need to address. This is part 3, and part 3 says we need to add a touch monitor so that we don't recenter the map when the user is manipulating it. And here's the problem. Let me show you. If I try and zoom in, you can see that the map is fighting me. That's because while I'm in the process of zooming in and actually getting new signals, new delegate calls back indicating that the position has changed. And so I can't zoom in because I keep getting recentered at the previous zoom level and that's sort of annoying. So what we want to do is we want to change this so that if the map is in process of animating because the user is touching it or manipulating it, then what we want to do is we want to not recenter on the position. So to do that we're just going to create a state variable to keep track within our code, and that state variable is going to be whether or not a map movement is in progress. Let's go up to our properties. Let's add a property which is going to be a boolean. And it's going to be mapIsMoving. And we will start off when we begin by saying mapIsMoving = NO. And we're going to change this down here so that when we get a call back, we're only going to center the map, we're going to say, if(self.mapIsMoving = NO), then we're going to center it. But if it is moving, then we're not going to do anything, we're not going to center it, we'll get another update and then we'll center it after that. So that's good. But we didn't have anything that indicated that could tell us when the map actually was moving. So, we need to do two things. We need to implement a delegate for the map this time. And the delegate for the map is going to be Indicate whether or not the map is moving. So we're going to specify that function. And in order for it to show up an Xcode, I'm going to come up and make sure that our protocol indicates that we are implementing it. So in addition to being a delegate for the core location callback, we're going to say, we also want to implement MKMapViewDelegate. So we're implementing that code. And the calls that we want to implement are changes for when mapView is right. Nope, that wasn't what we want. RegionWillChangeAnimated. All right, so if the region is about to change, then we want to say self.mapIsMoving = YES, and not surprisingly, there's a corresponding method, all right. It is did, change animated, in which case we set it back to NO. So for the time it's moving we say NO. We set up the delegate method. The last thing we need to do is we need to come to our story board ,and we need to say that this controller is the delegate for the map field. And now when we run it. And we decided to locate me. And I show up with that simulated stuff with that location. Now we can zoom in, and you can see that it doesn't fight us. We can zoom in without any problem, drag the map around, and move quite low, actually. Slow as we can, and then just let it go and you can see the map moving along there. Now if we want to stop centering on me, we can go to Lucy in the behavior. So we center on Lucy, but we're still actively centering on me, so. That would be something we could change if we wanted to. Right now we have to turn off location entirely in order to center on a different point. Okay, so that's the bottom line. That was the case study. We did three different steps in our case study. We did Single-View App. We set up our included our map view framework. We built out the the UI with three buttons, and we created three annotations that were located internally to keep track of those points. We bound those button actions to our code, and so that initially, when our view controller first loads, we create those annotations. But then, when our buttons are clicked, we center the map on them. In the second part, we added a "Locate Me" switch to the U/I, and we requested location permission from the user when we loaded the app, and then we assigned the delegate for the core location manager to keep us up to date when the user moves. And then the third part is, is that we assigned another delegate from the map view, so that when the user's manipulating the map view we don't try and center the map out from under them. So this is going to be the basis of your next peer review assignment. What we'd like you to do that's a little bit different is we'd like you to pick three positions that are of interest to you, and then demonstrate the similar behavior of what we just saw. All right, thank you for your attention. [MUSIC]