From the course: iOS App Development: RESTful Web Services

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

URLSession PUT for update

URLSession PUT for update - iOS Tutorial

From the course: iOS App Development: RESTful Web Services

Start my 1-month free trial

URLSession PUT for update

- So, as we've talked about, before, the four main operations in dealing with a server API are create, read, update, and delete. So, we just saw how to create an object on the server in the last video, now we'll talk about how to update one. For that, we use the PUT http method on the request instead of the POST. Also, we have to specify what object we're updating, so we usually specify the ID in the URL. Otherwise, the operation is very much the same as creating a new object on the server. So let's look at how that's done in the code. To show you how similar they are, I'm going to copy and paste the saveToServer function from lines 41 through 52, just below it, and I'll change the name of saveToServer on line 54 to updateServer. Now, this is also a function you'll be able to call on an instance of our music class. I mentioned there was a couple things we need to change. One was that the http method needs to be PUT, so we'll just change that, here, on line 58, replacing the POST with…

Contents