[MUSIC] All right so we've created a user and we've passed in the user name from the user name text field. So now if we have a good latitude and longitude, we have the ability to send those in with the call. So, let's go ahead and do that. Again, we may not have a current location, so that's why we use the optional chaining method here with the question mark. We don't have a location we just won't send it in. And you will see why these are optional in a little while. All right, but if we have them we can send them in. Now we have our requestUser object all ready to go, so we are going to make the function call over to our data provider class the UserDP class, to ask it to go and call the server and create a user for us. All right, so let's go take a look at how that call looks, how that function call looks, I mean. And I'm just going to put a closing curly brace to keep down the number of errors so we're not distracted. But we'll flesh this out in just a moment here. But I want you to notice that there's this trailing closure on this property. So we learned about closures as arguments of functions and we learned about the trailing closures and tactics that we're using at here. The dataProvider method, in this case, getAccountForUser, uses this trailing closure as a completion block that gets called when the response comes in from the server. Since that happens asynchronously, in other words, we don't know when the server is going to give us their response or even if we're going to get a response from the server. We use this closure as a completion block so that if and when we do get a response we can execute this chunk of code in the closure. And then do whatever we need to do to handle the server response. And we'll see how the argument looks like in the getAccountForUser or function signature when we implement the user DP class. All right but for now let's assume that we can make that call get account for user. Now, we want to implement what happens when we do get that response, so Inside of our closure here, we're going to say if returnedUser. So this is the user that the server is going to give back to us. We're going to say please create a user and the server is going to say okay, I've created the user, here it is. So if returnedUser.status.code equals 0, then we can go ahead and do whatever we need to do with that returned user. So we have inside of the SFL base model class, which we're providing to you. Some code, which will help you determine the stats of the return object, the response object. So that's where this status.code is coming from. Whenever you make a call and you're going to look at the response, check the status.code first. And a status of 0 means that there wasn't any error on the server, and anything that's not 0 means that some kind of error occurred. And we'll see how we can look at what that error was in a little while. All right, so now we made the call, we got a code status of 0, which means we either created a user or signed in successfully. And when we do get that user back, if we created a user, we will get back no hobbies, because we haven't saved any hobbies yet, right? We just created a user. Otherwise, if we put in an existing username that counts as a sign-in. So we'll get back that users list of hobbies that they've already saved if it exists. So we want to go ahead and cache those hobbies to disk on the phone. So that the list of hobbies is immediately available for the collection views on all three of our view controllers, the me scene, the edit hobbies scene, and the neighbors scene. That way we can just go to the phones storage and ask what are my hobbies, rather than always having to ask the server for what are my hobbies? Because that would make this application a bit more complex for you to implement. All right, so now that we know we're going to do that, let's look at how we can go and achieve that. So I'm going to say self.hobbies = returnedUser.hobbies. All right, so that should make sense to us. Remember that myHobbies has a property observer to update our collection view. So let's go look at that. I can Command click on myHobbies and see it's definition. Here's that didSet property observer, and we see when we set are myHobbies then self.hobbiesCollectionView will reload itself. Let's add in a function here to also save our hobbies to disk so that whenever we update myHobbies, the hobbies that are cached on disc also gets updated. We want to always keep those in sync. [MUSIC]