Build a Movie DataBase with Swift3 & iOS10 | Sandra L | Skillshare

Build a Movie DataBase with Swift3 & iOS10

Sandra L, Front Development

Play Speed
  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x
12 Lessons (1h 57m)
    • 1. Introduction

      0:39
    • 2. TableViewController

      5:46
    • 3. omdb API

      7:00
    • 4. Downloading Movies

      15:30
    • 5. Movie Class

      14:37
    • 6. Download Media

      7:42
    • 7. MovieWebView

      10:54
    • 8. Loading More Movies

      13:41
    • 9. Loading Movie Page

      7:31
    • 10. Resizing Cell Image View

      10:12
    • 11. Downloading Movie Rating (*)

      12:25
    • 12. Star Rating Emoji

      10:37

About This Class

In this class, you will build a movie database by uploading data from free the ombd API

b0eb0c87

Prerequisites & Requirements:

You will need access to a Mac computer running OS X 10.10 or later No prior programming experience is required. The course has been specially designed for beginners. The first chapters will walk you through the download and install process of the XCode 8 Application (to build iPhone Apps).

Transcripts

1. Introduction: In this part of the course, you will learn to develop more complexly out and user interface with the table view. You will use the table you to display at least of movies downloaded from the Internets. And we're gonna use the oh mdb FBI to query and download movie results. And we're gonna use parameters to also display movie rating. So the I am to be ratings and the U. Y Web you elements to embed a webpage directly on Europe and also something new. You're going to see how to use a u. I went few elements to embed include a webpage directly in your application. So let's begin with the movie database application. 2. TableViewController: So let's create and your project. And that's gonna be for the movie database movie DB for DB for database. And it's gonna be one single view, this one we're gonna out another few, and the overview will be to display the view. So for the movie which is selected so we're gonna have a table of you and then another view to display the details off one movie selected. So we're going to start by going to this story, boy. So as I was saying so we have this entry point to these view controllers we're gonna need another view to display this time a least off information. So that's really stuff movies, and we're gonna go select here Table of you Control. And this one is going to become the entry points to the application. So you see that for now. You see this error? So this is stewing DKB entry point to this view controller. We're gonna change that from here to here. So let's select this stable view controller. We're gonna go to here and check this one, which is is initial view controller, and that's gonna allow to move the entry point from here to here. Here you go. So for now, what we're gonna do, it's pretty. It's gonna be pretty simple. So I'm gonna create in your class for these tables, you controller. And I'm going to do that from here. Click rights. And then you foul. I'm gonna go to cook a judge class. So this one from source, it's gonna become a touch glass, and then you're gonna click next and here, I'm going to select you. I So that's gonna be from the current class, you white table view controller tear ago. And I'm gonna name this one. So I'm gonna specify movies table you control and this must be a step class. So here is the subclass off you white table view control here. So now you have some some boilerplate code that comes automatically So every time that you created and you've also in your class that interests from these current class which is the white table view controller. So basically you will need to specify the table. Do deter source. You white table, you delegate protocol. So this is automatically included and you already have some boilerplate code In order to indicate the appearance here of your table. You. So you've got this mark to indicate the number of section, which is gonna be always one you could have more, but in that example, it's gonna be on the one section. Then you're gonna have a number of rows, so I'm gonna pretend for now and then you're gonna have this function which is gonna be used to format each cell. So first the item to fire. So here, this is where you generate your cell based on a prototype cell which is in your story board , and here we're going to specify movie cell. And this one must much of the one that you add to your story about all night. So So the prototype. So it comes with a prototype by default here, prototype cells. So here you're gonna specify the item to fire, and that's gonna be this one movie cell. That's what just created Purna radically, and that's gonna allow to generate a prototype cell automatically for every room that we have so corresponding to a number of objects, data that we have in a collection, and that's gonna be a collection of movies that we're gonna get that we're going to download from the Internet using an FBI. So in applications programming interface. So we're gonna do that later. So for now, which is gonna check that we have set up the table, you correctly. So we're just gonna specify some text, So that's gonna be text label. So we're going to specify some text, so that's gonna be text label, And that's gonna be a party that's gonna come automatically with every object of type. You're right, table. You sell, you see, So we're using this method to dick you risible cell with one identifier for every index path, and then we're going to specify a text, and for now, it's gonna be something generate movie, and just to make them difference, we're just gonna pass the index path and that the party road, which is gonna return an integer and that corresponds to the position index for everywhere for a TRO. So if you have 10 rooms were going to be able to display 10 rows with the text movie, followed by the number off the room and because it works just like an array, so it starts at zero. So this is their indexed. We're going to start that one. So I'm gonna do plus one. So that's an inter dress, so I can use math operation right inside the interpolation syntax. So I'm gonna add one to every room, and we're gonna be able to read 123 so forth until we reach movie Tim because we have 10 rows. So we should be able to do that. Except that we're gonna need to also add this class that we have just created to these stable view controller with the identity inspector right here. So in order to be able to control this table of you problematically, we're gonna need to specify the identity. And that's gonna be with the movies Table of your control. So you must always remember the step to connect the view to one class and then let's see how it looks. So here you go. So we have released all general informations for now. So what we want is to display actual data from So we're gonna use one a p i which is going to be. And this is inspired. Inspired from the IMDB websites, you know about movies and actors, ex cetera. So we're gonna use that next. I'm going to introduce you to the OMT B a p I 3. omdb API: So here you go. So now you have So the up and movie database AP I So this is the Websites, and this is the euro in order to find this one. So basically, that's going to allow us to get movie informations that we can download from this FBI directly. So the FBI is what It's an applications programming interface, and that's a collection off classes, methods and function, which is gonna allow us to collect data from an external server and added to display it in our application. And this is developed by developers for other developers. So this is what we're gonna do. And the simple thing with this FBI, these applications programming interface is that you don't need an A P I key. That's gonna be prints simple to configure to set up. So let's go to the use age, and we're gonna be able to then get the data using one. You're also to make a request like so. So for that type of example, they're using a key. But we're not gonna need anyone actually, for our demo. Then you're gonna have different parameters, meaning that the way that you're going to configure your your or else they're gonna have partners that you can specify. So to return data for movies, Siri's or episodes you can specify this. I think it defaults to movie. So we're gonna use movie anyway for the format. So that's gonna be just, um, by default. So the value is Giessen. So we're going to be able to return values data in a GIs in format, which is a collection of key value pairs like dictionaries, and that's going to allow us to then excess of value for one specific e you're going to see . And if you want to return the tomatoes rating so you're gonna need to specify this one, because I think that by default, this is actually fall. So you're just gonna need to return. These one is true Internet to get ratings for every review and for search so you can do different type off our search you have by I d or title. So for search, you can specify so the type So which is gonna be just in format annals of the number of page, which is new because you can return as many page as you want. So that's gonna be based on the number of pages and results available. So we're going to see that next. I think this is specifying. So we're gonna check out toe one result example in the browser to see how it's displayed. But you can basically so maybe Joe Loop and return several pages interview to collect more data, more results and then display more informations results in your application if you'd like. So we're going to see one example. So, for example, right here. So that's gonna be you want example for a search? So let's take this one. We're gonna go to another time and here, So by default, this is just informant. So we're gonna be able to display Justin formats okay here ago. So basically, what you have here is one general key, so that is like, the highest level of the tree, and you can actually close this one, and you see that the total results if 3 18 Okay, so you have 3 18 results for this one and basically intended to return them all, so you'd have to specify, like the page right here. I guess because per page you actually have, um, like, 10 results. Something like that's you can actually collapsed them. 123 for 567 89 10. So you get so you have 10 results per page and basically what you're doing at her to get the exact number of page. It's pretty simple because it's 10 results for Page. You tick here that the little results and then divided by 10 to get like a not health page , which is available for this type of research for badman like here to specify the search, which is for Batman and then the number of page and I can select. So if we go back, I'm just gonna refresh here ago. So the 1st 1 is this. If I change the page number right here, like five, for example, I'm gonna have different results provided the Batman the dark nights. Okay, you see, so you can get more results if you like, and as discussed before, so we can also return. So the rating for so we have an I D. Which is returned for every search results. So for every piece of data, so you see that this is a collection of dictionaries with key value pairs so we can get an I d. For example, for the 1st 1 which is bad, man. The dark nights. I'm gonna copy it. We're gonna go back to this seamer later. That allows us to Maxim test try out. So the type of result which is returned. So basically a concert by I d and then click search. So you have this, You're all right here. Let's click on it. And we're gonna get this result, which is gonna give us, like, more details about the movie like the I am to be also, um, I d and also the rating, which is what we're interested in. Maybe. And here we see that we have a rating of eight point through which is coming from the tomatoes, like, ready and we have an image as well, which is provided only if it's the same that we have, and that's here on get this is the same. Yet that's the glancing image that we have in that result. So let's go back because, like, I just got into, like, just go back to the results. So that's the general results were at page. So that's the general results. So this is the page number five. And here this is the result for one specific movie Internet to get the rating. And this is what we're gonna be interested in. Actually, we're gonna do, like a query to make to return results for, um, movies to have a list of movies and also Geno the query To get one to do a query with one specific movie, I d to then return these results and be able to then access the I am to be rating. We're gonna do that. So if you're her two tests like different search options so you can use actually this way of searching so by title, you can search under. If you give you, like, a way to search for remove e or just test it's in the browser, like so for different movies. Let's try Superman. I'm gonna have a large list as well for stupid. And I guess here you go. So you can also have supermen and then and see what it returns so than above results. Two of five results and basically what you can do is tests what's returned. What we're gonna do next is creating functions that's going to allow us to um, do queries to the FBI. And the great thing is that we don't need to use any FBI key compared to other a p I that recorders for you to have a key. Otherwise the excesses denied, So we're going to do that next. 4. Downloading Movies: Now we're back in our exclude project. And what we're gonna do is starting to download Dina from peace ap, I so by doing an epi a request. So we're gonna use one year else starting with this one, actually. So that's gonna be a general one. We're gonna have access to many pages. So, as I was explaining, so you can access peach one page two and so forth. And the trick here, you can see that you have, like, 3 17 results we're gonna do because per page I mean research, super presentation. You're gonna have 10 results. So we're just gonna simply defied by 10 in order to get, like, the number of page, the number of pages possible. So we're gonna start anyway, with the simple query, like starting with that fur examples, I'm gonna copy it. So let's begin anyway, with the function that we're going to write in order to proceed with the download. So I'm gonna put that somewhere here. So all of that. So for now, this is in command. So this is functions for delegate methods. In order to control the behavior of a table use you can delete edit ex cetera. So maybe we can just remove that because we're not gonna use them in that project. So I'm gonna click delete a year ago. So here, we're gonna have a one mark, and I'm just gonna put, um Who mdb ap I just to keep things clear and organized. And here I'm gonna create a function which is going to download movies, and it's gonna take one parameter, which is gonna be a string. So that's gonna be actually the string that we got from the browser in order to do the request to get movies, Then we're gonna have a completion. So that's gonna be once the request is completed. So when we have downloaded the data, we're gonna be able to then return interest. So that's gonna be a collection that's gonna be a rate type in history. So that is a completion, and we're going to begin by creating a request. So that's gonna be a tusk. So that's gonna be with session, your real session, and that's gonna be shared. Then we're gonna create a requests, and that's gonna be from this session, and we're gonna proceed with the request with this function, which is data tusk with your own, so we're gonna have one permanent. So that's gonna be the euro that we're gonna need to convert. Actually, we're going to do that right here. I'm going to create a Euro object like so. So that's gonna be with this class euro, and that's going to be from a stream. And this drink is gonna be this one that we're gonna pass as an argument your old string a year ago. Then we're going to get some here argument data. This is what we're gonna use response and air if there's any, so we may get air, so we're gonna identify them. So we're gonna identify them if there's any error and after that. So we're ready to move on to getting the data from this request using this euro. So just so we goat step by step. So we're gonna get this drill that we're gonna define right here. So I'm gonna have one global durable here, so that's gonna be hard. Euro go MTV. I'm gonna call this one. It's gonna be a type string optional for no. I'm just gonna remove all of that because we're not going to use any editing functions. Here you go. And then I'm gonna finish, like this one in view, did load. And that's gonna be cool too. That's okay. So when it's gonna be time to call this function, we're gonna pass this as an argument in order to drive a query. So that's gonna be the first step. So let's go back to the function. So what we want to do now is before we proceed with getting data, so meaning that it will go back to that. So meaning that's like, um, going through this just in from its first. That's gonna be an array. So we're gonna access the value of that key search united to get that Marie. And then we're gonna look through each object of battery, which is a dictionary, and then get the value for the key that we're interested in. So that's gonna be the way we're gonna proceed. So first we're gonna check if there's any air it's gonna be even here, Neil. So if it's true, so that is one we can then go ahead and then proceed with the rest. And first we're going to do an optional optional chain and what we're doing here is a comparison and assignment at the same time. So what we're doing here is checking if we have any data valid to then assigned to this Constance, and that's gonna be only this is true. So if we haven't existing so if we have existing data and that variable, then it's gonna be assigned to data value. So that's a way to control the flu of the execution of the program. So then we're ready to do Do catch. So what we're gonna do is purse the jessen, which is returned from that data from that response. So catch is gonna be used to return if there's any error. So I'm gonna print if there's any error or something like error localize description in order to get, like, a description of the air 10% because of the error. So that could be like a problem with reading the Jessen. So that could be, like an invalid, your own anything in order to debug to the air. So when we're good, so that's gonna be in this book. Do. And what we're gonna do is getting a Justin object. We're gonna do that with try then, with this class. Just some serialization, Justin objects. Let me close that on the right. And then today, that that we're gonna parse is gonna be data valid. You know, like this one. Now that we have, like, Valley data for the option, it's gonna be with beautiful continue years, Perego. And that's gonna be as in Ennis dictionary. So this is what we get first and in his dictionary. Let's go back to the browser. So this is a dictionary starting here. So you see, like, this is curly brackets. So all of that, this is a dictionary. And then from that, we're gonna get the value that corresponds to that key, which is search. So let's do that next. That's confirmed here. Okay, so that's continues. And now we're gonna get the actually race. I'm gonna call this one just to stay clear some aviary and I should also and I should also call this one Justin dicked just to stay clear. So that is a dictionary here and here. It's gonna be a movie, very ordinary, under three objects, and we're gonna get that from just indicts. And that's gonna be with the key that's go back. Search I'm gonna copied from here. That's gonna be this. Keep search as an emissary. Okay, so here it goes, and that we get in every and what we should do, actually is starting to Prince. This arranges to make sure that we return like actual data, just like we see them in the browsers. We're gonna test that. So let's begin with that. So we're gonna need to know, uh, do a query, and I'm going to do that. I'm gonna finish to complete here for my requests. And that's gonna be with this Euro. Another thing, which is important. So whatever you want to perform a request edged it to be request. So that's gonna be with resumes. So we're gonna do here. Requests resume. That is an important step resumed. It's confirmed this one year ago, so and I think that I have to do that. Okay, Let's just they organize. I'm gonna do come and A and control I to clean a little bit. So here we have the Jew, because that's a lot off blocks. If and here, we haven't if, and that's maybe at this level, if if if Here. Yeah, so at this level we're gonna be able to do the resume. Okay, so right after here. So when we're done, the request that's gonna be here, I'm gonna put actually request here. We're gonna do requests and then resume. So we need to do that. So that's gonna be right to below the block. That could response to the requests you're gonna write. Requests resume. Okay, So let's say that and then call this function from feuded load download movies for now, which is gonna print something in the console. And we're gonna pass these objects string for now and for now, So it's not going to return in your way because we haven't, like, done like the the step off creating a local durable ready to assign object that we would have created. So for now, it's just gonna be going any to complete that later. So what we want for now is just to print this and that's gonna be in the console. So let's do that. Okay, so let's see. It looks like it doesn't printed anything, and that's because if we check like here, we have a message, which is transport security has looked clear. Text http resource load since it is insecure. And what's happening here is that since IOS nine, so x code has been blocking. So any http requests loads from particle that are considered insecure suggests, like, here. We've got an http, so it's not http s, which is it secure? So that's why we have this restriction here and in order to remove this restrictions, although we could possibly. So if this is available, sometimes it is. So just add let me see and ask you to P s, I guess doesn't seem to be available. Http. Us. That's right. That's Yeah, Looks like it is. So I'm gonna show you, like the way in the case. That's the s is not available. I'm gonna show you. So actually, we're going to do that right now. And then I'm also gonna show you how to update your info police in order to remove that restriction in order to allow loads from any Pirkle in order to allow http requests from any protocol. So regardless of it being http or https, So here you go. So we just need to add the S. So because now this is considered as a secured request. So now you have. So all the array that includes the dictionaries that corresponds to that response, and we're gonna be able to use that. So the other way that I wanted to show you is that you're going to do then update your info , Billy. So we're gonna do that just for the demo. So in order to remove that restriction of just in the case that your work with the protocol which isn't secure So you're gonna do this and that's gonna be transport security. That should be available pretty quick. So you're going to start typing transports? Well, maybe up transport security here ago, so that's gonna be up transport security settings. So that's gonna be a dictionary. So basically, what we're doing here is including a new perimeter in that in for police to the info policed is a collection off para meters for your applications. So here you have the general perimeters, including your bundle name. So that is actually the name of your product, your application product name. And here, what we're doing is adding an additional perimeter, and we're gonna then inside includes one berman, which is gonna be to allow arbitrary loads. We're gonna make sure to up in this once of this dictionary by simply clicking on it. So as soon as you see it pointing down somebody that you're gonna include, we want another key value pair inside. So you're gonna click plus, and here you're gonna have the options to allow arbitrary loads, and that's gonna be a boolean, and you're gonna simply change the value to Yes, And that's gonna be also another solution just in case. So that's gonna be the step. Just indicates that you're facing the problem off X code blocking http requests So that's gonna be with up transport security settings and just to show you how it looks, So here this is the format for probably list. This is actually a privatised. You can also have the formats as source code, which is gonna be an XML format. So let's look at it. I'm gonna close this. So here. You see that this is a dictionary so insider have all their dictionary starting the keys. So this is XML formats. So let's go all the way down to find so the last addition that we made and this one corresponds to our last edition which is here the key that corresponds to the transport security. And then inside we've added another dictionary. So this is another key with the value. So the key is gonna be to allow arbitrary loads. And we have assigned the value of truth. Let's go back to if I was to actually put false you can do it from here. And then we're gonna open it again, as probably least then you're going to see that this is back to know area. You see, let's go back to source code. I'm gonna set it back to true so you can update it. So the way that you want, So either using the XML formats or the permanent list, which is more like user friendly, probably. Let's go back to pregnancies. Then you're going to see that this is back to yes, here ago. So now you've met. So the the necessary steps in order to avoid any restrictions from X code. So now we know that re able to prints to get these data back from these Ural requests. So now we're ready to actually get so informations like the title the year are the I D that we're gonna use to then to a request in order to get the rating for that movie and also the picture. So we're gonna do that next. But first, what we're going to do is to create a class A specific class for this type of objects. Of what we want is to create a class with its own attributes, and that's gonna be like a sort of data type. And you need a type that we're gonna create with its own attributes in order to describe a specific object. And in that case, we want to create a class to describe the movie with attributes like the year the title ex cetera with the ideas. Well, so we're gonna do that next. 5. Movie Class: So now I'm gonna creates an object which is gonna be similar to hear a description off one object that we have here so meaning that this is gonna be used to describe every a movie data that we get from that search from that response. So we're gonna create in your fall on this one. I'm gonna name it that's gonna give type. So let's do that first. And that's objects. That's gonna be a new data type brewery. Gonna call it that way here ago. So now we're gonna describe so the attributes of that's particulate objects movie. So first we're gonna get a title that's gonna be very similar. Tube the data, a response. Then we're gonna get a year. That's not your type String. Then we're gonna get an I d. I'm gonna call this one. I am DB I d type string as well. There are mostly of type string, actually, the results, so only yeah, that's only strength so that she's gonna be strings for like and then type is gonna be string. We're gonna get also poster. Also, we're gonna get also posture older. I'd like to call this one thumb now. Strange here. So we're gonna do next is to create an initial Isar. So every time that we want to create an instance of that class, we're gonna be able to initialize this one. So with a title. So here, we're gonna have the perimeter. That's all gonna be required every time that you create a new instance of that class. Then year it's gonna be string. Then the i d is gonna be up type string as well. We're gonna get the type of type string. Finally, I'm gonna put thumb for the some mail and then so we're gonna be able to then assign to each attributes. So which ever value East past has been arguments When you create in your instant and that's gonna be self titled equal to title then self year, we call two year self I d It's gonna be cold to imdb I see. That should come up. Oh, my bets. Actually, I did reverse. It's gonna be itself. I am db i d equal to I d ok, and then so all right, the call to type Finally, it's gonna be self thumbnail that refers to this one. Just be quoted some so now we have created So our new class So we're gonna be able to use that. So when it's gonna be time to get the results back So when it's gonna be time to get the results back from these HTP requests and response that we get from that request. So let's go back to our movie data movie tables, you controller here. So we're going to remove these lines. So that was just the testing. We know that it works, and basically what we want to do is to look through every object that we have in battery. So after we got that object movie array, so we're gonna look through another to return, so to get every dictionary object. So we're gonna do that with, um, simply, like, movie for movie in with urine. And we know that this is gonna be a dictionary here, So we're gonna be able to then do something like, for example, getting the title from that dictionary object. So we've got that that's gonna be movie, and then we've got that key, which is title with the cap later. So we gotta be careful because the spelling has to be right. It must match. So it's not a small caps, so it's not small caps. Let's start with the cap later. So we need to take that into account, and then he we're going to specify the keep off the value that we won't get and that's gonna be as string year ago. And then we're gonna give the year saying so we're gonna get from these movie dictionaries . So each of them, actually, So that's gonna be one after another. Then we're gonna get the value for the key year, and that's gonna be as well as a strength. Looks like we've got an error. Yeah. Here. The problem that we have is that it's trying to get, like what we're trying to do is to get a value for what we know is the collection of key value. But the problem lease here, it doesn't know that this is actually a dictionary. So we're going to need to tell that to specify that this is an object of type and his dictionary. So here, what we're gonna do is actually creating objects of type dictionary, which is gonna be culture movie. So that's gonna be this local variable that we do. So that's gonna be this local venerable that we create in order to represents the object of that theory, which is gonna be of type dictionary. Although Exco doesn't know that this is a dictionary. So we're gonna need to create and you object, which is gonna be cool to movie as and ask dictionary a year ago and here, instead of just accessing from this object which has been known here to x code or swift, we're gonna then use movie dicked, which is known this time as an ex dictionary. So let's confirm that as well. Let's do the same for year miracle. So now it knows that this is a dictionary. So there's gonna be no problems with this syntax, which is to get value from a key, which is mostly it's drink. So that's always a string for the key. So now it knows we're gonna need to just confirm the type of itch which is gonna be string , and we're gonna continue. So that's gonna be I d movie Dichter. And the idea is gonna be with this key. I am DB i d also as a string. Then we're gonna get the type that we may use or not depends for We're still going to get it. And that's gonna be also with a calculator type. Finally, the poster gonna copy authority. And I'm gonna create the constant that's gonna be some no as well movie addict. And that's gonna be from the key poster. Also is this train. And now with all of that, we're gonna be able to create our own objects without a clock. So that's gonna be an instance. Off the class will be. You're gonna see that as soon as a top actually movie and then first pregnancies, I'm gonna have these initial Isar very convenient. And then I'm just gonna need to fill out with the corresponding value that I want. You specify for this new instance off movie, So that's gonna be year Subtitle title and then year year That corresponds to this. And then for the idea it's gonna be I d the type type. And then for the thumb, it's gonna be some mill. But we're gonna get here. Finally. So what we wanted Stoop then a pen, so at that to one another collection. So I'm gonna need to create another variable here and that's gonna be I'm gonna call this one. Move your area. You already have it here, so that could be with them. That's movies array a year ago. So the difference here is that we don't have in us, and here it's in its and this one is going to include object of type movie That's gonna be a collection off movie objects. I'm gonna pass this. That's gonna be movies or a this one that includes you see, with the objects within s we're gonna penned H in your instance that recreates. So that's gonna be 10 results from that response we're gonna create. So we're gonna have 10 movie object in that room. Finally, we're gonna have another global variable here, which is gonna be movies. I'm just gonna call it that way with movie objects and let's go back. And finally, what I do is when once my request is successful, I'm gonna need So once my request is successful, I create any object for every data returned. Then I append the results movie instance to my movies are a local variable. I'm gonna pass this, as in the completion that expects injury, that's gonna be movies all right here ago, and then we're going to be able to then go back to here to complete this function. It's confirmed completion escaping. Okay here, remaining to specify that this is, as in a survey, because here we have, like, here we could also do something like So because we know that this is gonna be a collection that's gonna include movies, objects of type, movie, and then replace here like so Okay, and then I'm just gonna confirm, okay, so I'm just gonna need to add a bang to confirm Here you go. Should be fine. It's billed to see that we get no error. Okay, so it knows automatically that this is an array. When we specified that went OK, so either way is fine. So now we're going to go back to the top two, then complete dysfunction, because we're gonna use that. So as soon as we're done with the request, So using this euro, we're gonna then assigned to self movie. So this is a global terrible. So the rate which is returned, that corresponds Sue, That's hurry. Here. So this is this a Reba tweet assigned to self movies and the other thing that we're gonna need to do is to So there is this table you we're gonna need to refresh the data, reload data. So each time that you get objects values data from the web so you're gonna need to refresh your data in order to display them fresh in your table. You And so now we're able to actually use this data is to display in our table. So let's do that. So here, at this level, instead of just hard coating, it's gonna be movies, counts. And then here's what we're gonna do is to display I'm gonna first get one movie cell on, and that's gonna be from movies from my collection. So I'm gonna get the one that corresponds to that Sabine Exposition. But that's gonna be movies and then index past row, and that's gonna be as movie objects. And then here what I'm gonna do, IHS because I want to display the title. We're gonna access that, then here the attributes title and we're gonna need to confirm because they're old optionals here. Gitell. So the way that we define it, there are all optional, so we're gonna need to unwrap them so when it's gonna be time to use them a year ago. And I don't know if we have specified a different format for here. We're gonna need to do that. So in order to have, like, I'm gonna open this panel. So for now, we have a custom type, so we're gonna have this entitles you can click on it in order to have different options of presentation for yourself. So let's select subtitle in order to get this extra here, attribute for yourself. So that comes automatically with the content view. So we're gonna have the title label and also another label, which is gonna be subtitle. And we're gonna then initialize this one here as well. So that's gonna be with detail, text label that we're gonna need to confirm because they're all optionals under the same here. And then I'm gonna sign so something like the year. So we're gonna So then I'm going to sign something like the year. So we're gonna get the title hurts, and then we're gonna be able to read the year underneath and I'm gonna control. Here you go. So that's pretty much it so does try that. So we're gonna run the application again, Introduce your least off movie objects And here ago, So now you've got the title and the year as well underneath. And we should also be able to get an image. You so the thumbnail. So you know that we're getting actually the thumbnail from here from our request. So we're gonna try that. So every cell comes with an image you as well. So we're gonna use that's with an image that's gonna be the Prodi image. Then we're going to need to use the, um, image function. Then we're gonna pass. So that's one pretty named We're gonna pass the movie cell and we're going to use that attributes, which is the mill, and confirmed. Let's try that. Let's just confirmed this attributes because this is an optional. So the thumbnail is also a year ago that you're using. So if we check actually, the response which is returned here, So you see that you've got this year also, this is also Https here ago is in order to give that, so we're gonna need to perform another request. So, basically, just like we did in order to get the least of movies by doing our requests and http request here. So we have a session than a request. We're gonna need to do the exact same thing in order to down with the media this time and then be able to display a thumbnail for each movie. So we're gonna do that next. We're gonna down with the media in order to display a thumbnail for each movie for each movie. 6. Download Media: Yes. And now we're going to see how we can download media. So we've got that download movies function. So we're going to write this right below. That's gonna be funk download media. This one is gonna take as well a strain. So just gonna meet Media String or Thumb String because you know that we expect actually this some information in order to drive a query. So then we're gonna get to completion as well. So that's gonna be very similar to this Sexually this index religious copy. It's just no replace with whichever data that we want to return the type, the return type, and that's gonna be actually here. I'm just gonna you raise that it's gonna be a major data gonna call it, and that's gonna be off type data. So basically, what we're gonna get in return is a data that we're gonna use to create our image. So after doing so, the query, the request So let's do that. So first we're gonna get we're going to convert that into a euro. So just like here, So we get a string, but we want to get so we're gonna need a euro formats in order to then perform the request . So that's gonna be in the job. You're also using this thumb string value that we're gonna pass as an argument. They were gonna do a request very similar to the first example. I'm just gonna do everything on one line. So that's gonna be Euro session. Let me see. Because you have got Okay, I've got one extra baroness is Looks like Okay, so that's maybe you're all session, then shared, and I'm gonna go. I'm gonna do Street Deter task with euro. And that's gonna be this one in order to get data a response and errors if there's any here ago. So that's gonna be Dita response an air, and I'm going to do the same. I'm going to check if there's any air first with if air it will, Jameel. So if there's no air, so we're good and then we're gonna check if we have some valid data from that request. So that's gonna be data image, A culture data here and IV. This part is good. So meaning that we're gonna get to comparison first and then an assignment if this is valid . Okay, so we cuts like data married for this data response and then celestial surpass here because this is expecting and arguments, I'm gonna pass this media euro, which is a type euro, which is a type euro to Jura request. Here you go. So next what I'm gonna do is simply use these data to pass. I'm using the completion and I'm gonna pose this data image. Did you confirm that? Here you go. And if there's any air, so we're gonna actually specify this year, So here we have. If so, that is the optional chaining. And then another. If here So that's gonna be else. We're gonna print the error. If there's any, just in case error, localised description and finally important step. We're gonna need to also resumed the request of that's gonna be here right below this block in order to do a request and that's gonna be with requests, resume, resume, like some here ago. So what's left to do is to then call this function from the cell configuration directly. We're gonna do that here, and I'm going to do download media and I'm gonna pass actually this string information as an argument, then it's gonna return some data. So we're gonna be able to then create out of image from this data return. And instead of using this burner, it's gonna be You can also creates an image using this function with the permit, er, data year ago, and then I'm gonna pass data. So this time we should be able to get imaged, so thumbnails video. So thumbnails visible for every cell. So let's give it a moment. So this is also a query. So that may take sometimes. Here you go. So you're starting to see some images that takes a bit of time so we could have something so we could do something in order to remedy. So this problem of having to wait for the image for the image to display, first of all, so at the place of the query. So first, what we're gonna do is using this function which is gonna allow to perform this completion . So on the main threat. So something with Iowa's it is possible to perform simultaneous task a synchronously. So something with IOS is that you can perform multiple asynchronous test so simultaneously on the back threat and the main threat and anything which is related to download The data from the Internet is done on the back thread, but at the same time, you can perform task in order to update the u. Y the user interface by performing. It's on the main threat. And this is something that we're gonna force to do by using dispatch que and then it's gonna be main a sink for asynchronous. And we're gonna use this one execute here ago and we're gonna forth this one to be executed . So as we download the data on the main threat and another thing that we're gonna do because I am providing here image So this movie being foul So we're gonna have this one to our project. So that's credit by simply dragging over to the project year ago. Click finish. And basically, we're gonna add this as a placeholder in the storyboard so you can go to your cell here. So you're going to see, like, this one from the document outlines. So that's gonna be easier here, And I'm gonna have this attributes that you can complete so you can provide an image information so you can provide with an image name for these attributes and then we're gonna have this one, and that's gonna create like a placeholder for this space. And we're gonna have, like, an impression that this is displaying getting this way with a little bit of delay. So that's gonna be a little bit smoother. So let's try that. So now that we've updated the code with dispatch Main Q and also added a placeholders, let's shake this up. So that was actually much faster. And actually, it's gonna date like, because for now, it's just a place holder and you're going to see that, actually, sometime it's just gonna go smaller because this is getting this is updating. Okay, so that's pretty good. And we're gonna format a little bit differently. This, um, this rose showing. So the title, the year and also the thumbnail. We're gonna do that a little bit later. What we would like to do also is too display, actually, like the details of that movie. So when you click on it so we have a different view where we can navigate to energy to actually see the page from I am to be so we would have these view controller. Let's go back to the storyboard that we can customize to display using a U ey. Web. You so the actual webpage off the movie, which is selected, So let's do that next. 7. MovieWebView: So what would do now is focusing on these view. Controllers already have a class associated to this one. So what's left to do is just to personalized this one. So we're gonna have a July with you to begin with, and that's gonna be very simple. So we're gonna add this You? Why web you? Which is gonna be then used to load a request using one euro, which is gonna be used to embed Web content and enables contract navigation. So that's gonna be loaded from a euro. So that's at this one to the view. Then we're gonna add constraint. So that's gonna be that's going to cover the anti reviews that is gonna be zero on each side, no margin year ago. Then we're gonna confirm and just remove that gap. So we're gonna drug this over all the way to the top and finally update with constraints here ago. So now let's go to we're gonna have been a side by side. So we're gonna use the assistant editor you to add an outlet right away for this web. You so that selected and then drag here, and I'm gonna call this one movie web view. There you go. And what we're gonna need to do is to then go back to the movies table, be controller because we're gonna need to pass data from one future, another to allow them to communicate. So we're gonna use for that The prepare Passaic with function. So let's use this one in the movies table view controller. I'm gonna remove those comments signs and also this commence. And finally, some just movable that as well to give things clear and simple. So here we have our function, so we haven't created a sick way yet. So we're gonna go back to the storyboard because what we want is to allow the user to Segway from by clicking on a cell by selecting one movie and navigate to this view. So we're going to select the cell, then press control, and here you're gonna be able to then drag over to here. So as soon as you see this, like classing up, lighting up, you can then release. Then we're going to select the type of cigarette which is gonna be show this one marital. So now we have a Segway, and that's gonna allow to communicate so from each cell that you select each movie that you select. We're gonna be able to navigate from here to here. And we're gonna give these Seguin and I don t fire. So you're going to see that we're gonna be able to use that later, So that's gonna be good to movie. But that's maybe the item to fire off this sick where? Perfect. So for no, there's nothing, but we're just gonna try it out for now. Just to see this is like the mechanism is welling place. And there's nothing happening pronounce because, like, right now, So we've got no view. Okay, So what we're gonna do now is go back to this here view controller and what we're gonna do is allowing to display some data. So by using so actually this prepare for cigarette function. So first, what we're gonna do is a check. We're going to check if the cigarette identifier is equal to the same identify here that we have defined. So which was good to movie? Because here, in that instance is true that we only have one cigarette, but you could have multiple sake. Ways for more complex architecture, off data for more complex architecture of an application, so you could have multiple views and multiple say, quit. So you're gonna need to then specify. So then you're gonna need to specify different cigarette and two fires in order to be able to know where you want to navigate using those. Identify IRS. So this is why we're doing this step next we're gonna then define So the destination pub that's sick when so that's gonna be with So we are navigating to view BC. So the view controller, OK, and that's gonna be with Segway destination as view control. So we're navigating to that view control, okay. And what we're gonna do in that view controller, is we're gonna do something simple just to test that this is working properly. I'm gonna create one global variable here, and that's gonna be movie. We're just gonna give type movie. Here's And I would bet this global variable available in view controller and what we're gonna do with that. So first of all, we're gonna want to gets, like, a reference to the movie row. So the road which is selected in our table, you referring to one movie and we're gonna do that by getting the index path. And that's possible to do that by calling one attribute, which is index for Selected Room. And that's going to return an index back. You see here ago and on every index bath object, I can have two priorities, which is road and section. So basically, we're gonna be able to then movies electric, then access to our collection of movies, then use that in. Expect that I've called Index and then get the room, meaning that you were gonna be able to get the room number corresponding to the movie the cell selected. Let's confirm that, actually, that's gonna be with a bank. And now I've got the movie selected so meaning that when I click let's print. Actually, uh, I'm just gonna actually print index were just to make a quick demo of what we're aiming force of what we're trying to achieve here. So you're going to see that each time that the quick So you're going to see that each time that I click on the cell, I'm gonna be able to return the specific corresponding in exposition of that cell. That's right with the 1st 1 which should be. That's right with the 1st 1 which should be zero. So although this is navigating to the next view, so that's like here. So here you have the number. Let's try with another one. We have no way to navigate back. So we're going just that that as well. So there's gonna be the mechanism that we're gonna set up with the navigation controller. Let's select this one, which should be one Batman, the killing joke. So here you're going to see number one, and that corresponds to my room. So we know that we're able to identify the room, the index position off the rose electives. So we're gonna be able to use that to you, Then pass that information to the next to the destination of your controller. And we've got a reference to that Destination three controller. So we're gonna use that and then refer to that a new global variable that we have created, which is going to have type movie that we're gonna make equal to movie selected, meaning that before we actually Segway to the destinations, you controller, we're gonna be able to pass. So the value that corresponds to the movie which is selected. So meaning that we're gonna get the index position, then gets the movie. So the movie object that corresponds to that movie collection and then pass it here movie selective, then assigned the value of the movie selected to hear movie, which is part of this. This your controller right here. And we're gonna be able to use that. I'm gonna print something here. I'm kind of print something like very simple. Just to test the movie selected is and I'm gonna use movie. That's an optionals. I'm gonna do this and then title Perego. So we're gonna be able to read this, which is gonna make it clear so from one future another, you're gonna be able to get the data from that view. Controllers of the source that you have selected first before you said, Will you navigate to the destination in order to do something with that object which is gonna be to display the corresponding euro page. So let's begin with that. Okay? Badman So this one year ago movie selected is badman assault on Markham. Our game. Sorry. So this try another one, because that's what's pretty quick. We're just gonna look at what we're selecting before we actually click on it. So let's try the killing joke or maybe No, Um, this last one. But man, beyond return of the Juncker And here ago, you can actually read it. Movie selected is Batman beyond return of the Joker. So we know that we're able to have those two view controllers communicates between each other, and this is thanks to this caution here, which is prepare for Segway. So what we're gonna do next is to actually use this view, So this will view to display the euro page, so meaning that we're gonna be able to use. So there is So there is actually the society that we're gonna use because if you go to IMDB , you have this furious. I'm just taking one quick example here. So the way that the euro of the so the way that the euro off one movie page on the IMDB website the way that the euro is constructed for one movie page on imdb dot com is that you have I am to be not come entitle then the movie I d. So we're gonna use the same syntax in order to display the movie page from this source corresponding to the idea. So if we do that for actually this first title, which is Batman, the Dark Knight? I'm gonna re please. So if we do that for this title, which is Batman, the Dark Knight. So I'm gonna do I'm gonna use this I d and replace this segment to return the page for this Batman movie a year ago. And you've guts the bar story, Major the thumbnail pretty good. So this is what we're gonna do next. First we're gonna need to add and navigations controller, do this structure here because that's gonna allowed to add a mechanisms to that's going to allow to navigates back and forth between the source and destination. So we're gonna do that next and then also work on displaying the movie page from the movie which is selected in that 8. Loading More Movies: So here we're gonna see how to load more movies in order to get more results displayed in every table view controller. So we know that we have multiple results available. So we're gonna need to do a query. Actually, two targets, another key. So if we look here at one search example for Superman Page 10. So it's going to return on Lee. So 10 results for the page 10. So if you go, if you collapse this one, you're going to see that you have this key that corresponds to the number of results available. So we're going to do that. We're gonna do a query to get that value and then before multiple requests based on that, using the same euro. So let's do that. We're gonna have another function, so I'm gonna go right below download media. Actually, I'm gonna call this one query number off pages, number of pages, and this one is gonna take also one year old because we're gonna need to actually do the query on that specific Curiel using Lee a query name. So you see that there was a query which is for Batman or Superman, of which Pepper movie title interests that you have. We're gonna do the query with vets that's gonna be of type string. Then we're gonna have a completion, and that's gonna be pretty simple. Actually, we're going to return and it an interview. So I'm gonna call this one. Um, I'm not Have you Type it and that's gonna be just like here. We're gonna actually copy it just because we're Lisi. I'm gonna copy. Then just replace with the right details. Just replace here with, um I'm gonna put movie euro now, Query, You're all just to change it. Quarry euro. And then it's gonna be from this here, your old string right here. And then I'm going to replace you with Query. So we're gonna do a query on that girl, and if there's any air, so there's no error, so we're gonna be able to proceed. And, of course, we're going to need to resume the request in order to perform the request. Oh, I'm missing one calling here, so you know, you're all string of type string have been completion here of type completion handler. Okay, so that's rectified. And basically, it's gonna be just like we did to download the movies information we're going to need to do a do catch. So if the data is valid, who lets hope you that as well I'm just gonna Pete, I'm just gonna copy all of that, and I'm gonna piece this inside here this block. So if there's no error, but we're not going to be using all of it because what we want is to do a query on one specific you, which is gonna be the number of pages. So I'm just gonna remove all of that because we're not gonna need to do any look to look through any objects in an array. So instead, we're gonna have here are variable, which is gonna be a string of type string, so that's gonna be enoughto pages. I was gonna be of type String, and we're gonna use that to then assign the result to here just like we did. For that Was the raid the movie rate, but instead, So here, Data valid. So we're using something different here. Okay, so something we're gonna do as well, so we're gonna do a check, so there's gonna be a data. Okay, We're going to use valued as well so that's gonna corresponds to data. So if the data is okay, we're gonna then be able to proceed with the Jew catch here ago. So we're gonna go in sequence. And so instead of returning so the array that corresponds to the key search. So that was a different key. So we're gonna go back to one query just to check that. So you see that you have. So when you close this one search, so this is actually total results. So this is what we want to access. So we're gonna be able to display so this number, which is of type string objects and so I'm gonna piece that here to replace, and we're gonna actually print it, So we're gonna start with. That's just to see that this is actually returning. So what we're expecting just gonna put number off pages. Here we go and looks like we've got an error here is because I forgot the common year ago. So acquiring them both pages and that's actually here as a strain here. I'm gonna need to confirm this one because I put this one as an optional. Okay, so let's start with that, So I'm gonna call this function from view did load at the start of the up. And that's gonna be query on both pages that I'm going to do with this Sam Euro and we're gonna return an intimate That's gonna be later. No. And we're gonna complete with some code here as well. It's going from this room. Here you go. So let's run that. We're gonna be able to print in the number of pages in the console. So now we know that we can use that information in order to perform multiple queries. So basically, we're gonna have this function which is down of movies inside this function. So we're gonna do a curry to get the number of pages first and then used the number here so that it isn't int that were returned from that curry number of pages function. So I'm gonna need to then past this in the completion number of pages. And here this is a strength. So you're going to see you can anticipate a problem here because here this is expecting an into an integer, and we're oppressing his train. So if I try to build, we're gonna get an error because it says cannot convert value of type string to expected argument type. And so, basically, simply, we're just gonna wrap this number of pages with an end like so and that's going to resolve the issue. I just gonna need I'm just gonna need to confirm to interrupt. That is optional farrago. And that's good. That's gonna be good. That's gonna allowed to then use this end value. So here, at this level and basically what I want to do with this number, so I'm not gonna be doing so queries for the number off results I'm gonna need to actually , I should name this one number of results. But what we want is ultimately is to get a number off pages available based on the count, the number of results. So that's gonna be let's I'm gonna create another constants here, and that's gonna be results counts. I'm gonna call, and basically I'm gonna let me name this one count in state. I'm gonna do count divided by 10 because we have 10 results her page, and that's gonna low to return the number of pages based on the number of results. Then I'm gonna use this result counts to do so that before I in. So I'm going to do one because I want to start with one, because for every query, so that's gonna start with page one. So I don't think that there is any query available for Beijing zero. So we're gonna do Page one and then we're gonna use results counts in order to then gets arrange, meaning that we're gonna need to, meaning that we're gonna be able to perform a look for every counts off pages that we have available, you see, And here what I'm gonna be doing is not to use the same euro each time. So I'm going to replace this one, actually, here, I'm going to refer to the same one. So at first, we're going to acquire with this one with use generic. So first, we're gonna do a query with any euro with a page generic, and then we're gonna replace. We're gonna have deep this one with a page number, and that's gonna be with this local variable placeholder. Basically, it's gonna do accounts, so it's gonna being corrected each time that we execute the loop until it reaches. So the number off pages available so that's gonna be starting from one than all the way to . For example, if you have 20 pages, so that's gonna be between one and 20. The look it's gonna be executed in order to return. So to perform a query and then return So the movie is corresponding to the page. So and here is not gonna be just to assign an array because otherwise we're gonna overrides with a new Yuri Each time that we execute the loop instead, we're gonna use plus an equal in order to at a Nuri to the objects already available in movie. So we're gonna add It's gonna be added dependent each time that it goes through this. So let's do that. So this time we're gonna be able to actually, I'm gonna put a break point just to show you how it works. This time you're gonna be able to see that we're gonna get a query for different euro. So it's gonna go in sequence 123 and so forth. Let's run this And here ago. So the program has just stopped as we have so instructed because here the break point is going to be used to stop the execution of the program so we can inspect what's going on. So to check, if the program is performing, I was expected. And you're gonna be able to then continued by just here. You have descriptions to continue program execution and for no, we start at number one and we have a result counts that is equal to 31. So that is 317 divided by 10. Because we have 10 results. But Page, So this is what we get from the query. So to get the number of pages than we divide this one by 10 to get the results counts, and that's gonna be for the number of pages and basically here where we want to run this query. So as many times as we have pages, so that's going to be 31 times. So let's just continue by just pressing here, and I'm going to see that we're gonna then continue to increase. So this local terrible inter due to do a query for each page, you can see the number increasing. Here you go. And that's gonna be until your reach, and then the 31. So then the loop is going to stop executing because we have rich the end of the range as we have defined 27 28 to 29 then 31 and here ago. So that's the end of it. And here going to see that now movies, which is for now, equal to zero values. You're going to see the number of values increasing by 10 each time because we're gonna be able to add 10 new values for each new query. Because that's gonna be 10 results per query. That's gonna increase by 10 each time until we reach. So as we had seen. So the results count Waas Ah, 31 33 17 That should be equal to 317 and then it's going to stop and look alike. It's not actually, I'm just gonna stop that, then just running normally it looks like we have, like, way too many results. And actually, we have defecated. And there isn't for that is because here we're doing this query from the same murals and multiple times here. So the based way to proceed would be true, actually plays this one at the top to initialize this one right here. I'm going to remove that here. So we're gonna be able to establish this query to do it one time. And actually, I'm gonna do it from page one, because that's gonna be anyway, the starting points. No, I'm missing the course sign. And now, So we don't need to unwrap this one because this is no longer an optional same for here, no longer an optional. And so now. So we are able to load. So the amount so of movies which is like that corresponds to the complete lease, which is 317 in total. See that you see, actually this one scrolling down and it's not duplicated as well. So it's fun. What's left to do is you see that we have images with different sizes, so we want to format the cells differently. So to have so that's gonna be the title, we're gonna be able to also change the color of the title subtitle as well, but mostly the images that we would like to have the same size and maybe round it. So that would be the bonus, the extra feature to make the images rounded. So let's see that next. How to format the cell a little bit differently. How to customize it 9. Loading Movie Page: Okay, so let's add one navigation controller to begin with. So I'm gonna select this movie's table few controller, we're going to select a teeter than embed in and navigation controller. And you see that this is gonna add the one mechanism. So using this navigation burns with that comes automatically and you're gonna have, like, a mechanism allowing the user to navigate back and forth. But that's gonna be way more convenience. We're gonna try that, too, right away. Actually, you're going to see that we're gonna be able to go back after navigating to the destination you control her year ago. Let's try this one, and I can go back. You're so that's pretty good. So we're gonna use that. So next we're gonna then configure the view control in order to then displayed. So using the movie Euro, Actually, the movie I d. So we're going to start by creating one euro. Now this one is gonna be I'm gonna do that with Euro Now that's gonna be with this dream here ago, and we're gonna copy this euro example here, so we know that we can use the 1st 2 segments of first the protocol, the domain name We're just gonna need to replace. So that's gonna be a string. And we're just anything to replace this with the i d off the movie which is selected, and we're gonna simply use so our movie object and then excess the imdb here. So value that corresponds to the i d off the movie. So that's actually the i. D from me. I am to be website and that's gonna low to Ben. Creates a specific customize your own urine to load the specific page off the movie which is selected. And after that, we're going to create a request. So that's gonna be requests using that euro, and that's gonna be with your own requests using one euro a year ago. And it's maybe this one that you just created at the top. And finally we're gonna load So this page using So the movie web you outlets using lewd request and requests Miracle. That's all there is to it in order to display embed one webpage inside our replication. So we're gonna try that we're gonna be boot. We're gonna be able to load page views in the application. So each time that we navigate to the days each time that we navigate to the destination. Let's try that. So that may take some time and here ago So now you can read. So, Batman, the movie, let's go back. Try another one, Bettman beyond. And here goes. And now you've got the page that corresponds to this movie and you can even navigate, like, see full, serious cast. You can then go back so you can navigate within this web content. Then go to other pages and then to go back to your released, you just gonna click back. The other thing that we could do is displaying the title of the movie here at the top. That's gonna be pretty simple. So we're gonna use the same thing here, and we're gonna simply refer to sell title for these. You control it and then assign this. Let's try that again. This time, we're gonna be able to read the title of the movie right at. That's up on the navigation bar. The killing joke here ago that works for you. That works pretty well. That works pretty well and we can even like, watch trailers. Overpopulation is disease from viruses. The cure. We're doing an extinction. It's like to go back, click down and go back. Apocalypse. We may have a trailer for this one as well. Yeah, but that's a cartoon movie, I guess. Okay, so you see the gist of it anyway. So what we're gonna do next is we're done with this part, so we know that we can navigate, then display movies and then Levy Gates within the I am to be Web content. Where we're gonna do next is for now. So we know that we can return 10 results for every request because we have access to Let's go back to the movies table view controller. So let's go back to the top here. We see that we have this year also with a page. So there is this parrot a page that allows to display one page in particular because you have several requests available because you have several responses you have. Let's numbers bones. Do you have more than 10 anyway? So every time that we do a query, so let's go check out, actually, So let's go check out here. So here. This is for the page Number two. You can also do request full page number three and so forth. So what we're gonna do is allow to do a curry, you know? Did you include all the results off the query? So here you see that you have this key at the same level of search that allows to return a number. So that's actually a string, but that includes actually a number and above results. And we know that we have about 10 results. So that's actually exactly 10 results for every loads. Request for each page gonna check before we're going to see that we have about 10 results, 10 dictionaries, objects. And basically, we just need to divide this by 10 in order to get in above pages that are available for a query corresponding to Bettman, for example. And we're going to see also how to perform request, actually for different like type of query, because now, like for now, it's Backman. But we could do super moan a year ago. So, uh, you could do whatever you want and here, you see, that you have about and here see that you have 205 results available. So that's love pages that we can access to in order to display movies about Superman, you seem so what we're gonna do is allowed to joke reverie in order to get the number of results available and then perform multiple queries interview to display all of them to display the totality of results available for one specific query. And we're gonna need to do look to perform the same request to multiple times that we're gonna need to do a loop in order to perform the same request multiple times based on the number of pages available. So we're going to do that next. We just need to do a few calculations in order to do that query multiple times based on the number of pages available, Let's to see that next. 10. Resizing Cell Image View: So now we're gonna go back to the storyboard because I'd like to format this cell differently. So I'm gonna start by simply increasing the size of the cell. So we're gonna go to the table of you. So you're gonna go to this level and we're gonna go to the size inspector, the utilities first and then size inspector, and you're gonna have attributes for the rule height. So I'm gonna change the value to 80. So that's gonna be much bigger here ago and also as we're here. So I'm gonna also change the color off each label here. So I'm going to attributes Inspector than here. I'm gonna change too Dark gray. Same for the subtitle. So that's gonna be dark green. And now So we have this movie images that would like to resize differently, So we're gonna need to do that programmatically So I'm gonna go back to movies, table view, controller, and in order to do that, So that's gonna be off course from this function right here, which is the data source methods for the table you. So we're gonna be able to control a little bit more of the presentation of each cell. So that's close. That just to have a larger view. So I'm gonna have another function here. We're gonna call this one resize cell image you and it's gonna take one paramedic. So meaning that we're gonna targets each cell, which is of type you white table of your cell. And basically, what we're gonna do is draw. We're gonna draw, like, looking image from a context. But for that, we're gonna need to spacey high a size. So I'm here. I'm gonna create an object which is gonna be a type c g size. So here, I'm gonna actually define this side that I am expecting for each cell. So that's gonna be with CG size, and then I'm gonna be able to specify a with and height, so I'm gonna put 55. So I'm putting dogs ever because this is expecting afloat, and I'm going to use this method. So this function, which is call on you, I graphic that is your biographic gin image contexts. And I want the one with options. And here we're going to specify So the size that I've just defined for opaque I'm just gonna put false and then the skill who that's going to be based on the scale off the US screen. And then I'm gonna write main skill. And also we're gonna defined So the position of this one. So this time we're gonna have an object which is gonna be a type See, directs. So I'm gonna call this one, so that's gonna be the image that's retargeting. That's gonna be image Rex that is gonna be with see, direct. And here. So you're gonna type and you're going to be able to initialize this one with an X Y coordinates. And with and height, that's gonna be 00 sufferings where you could put zero. Just keep it simple, but you know that this is a float and for these were just gonna refer to item size with and item size height because because we have already defined this one, so that's gonna be similar. And finally, what we're gonna be able to do is to draw an image from the image you now that's gonna be attached to the image priority of the image you. So we're gonna draw and we're gonna use the frame definition of the image Rick that we have defined right here and here. I'm gonna confirm this one because this is an optional. Actually, for the party here it is gonna be in a nups ups. Here you go. And finally, we're going to give the image from this image that we have created using this context. So that's gonna be with you. I graphics get, Imagine, from current image context. Carol. So we're gonna do that for now on what's left to do is just to finish, because here, you see that we're specifying So you're biographic speaking image context, and we're gonna need to end with you. I graphics and in May age context. So we're gonna finish this by just reading this at the end. So that sits So that's all there is to. It's So what's left to do is to then call this function from our methods. Configure so and basically I'm gonna do that right inside. So these down on media, because as soon as we get this new image that we assigned to the image you pretty of the cell of each cell, I'm gonna then resize it. So I'm gonna do self. I'm using self because we're inside a closure and I'm gonna write precise ALS resize itself image you and I'm gonna use I'm gonna pass cell as an arguments, which is up top. You wait tables. You still right here. Like so Look it. So let's try that. So now we're gonna be able to see that now we're gonna have So we have changed the rule height. So now this is Katie, and we've changed the color of each label. And also, we have resized each cell image view to be the same pretty good, so we could keep it that way. So that's pretty good. So it looks like this one hasn't actually downloaded yet because this is like because of the placeholder that you could resize because now we're using this 55 55. So just a year there's no difference when you when it's not yet downloaded. Because when you look at this movie images, I'm not sure that this is actually 55 by 55 so they think that you can do just to keep things similar. So as soon as you start the up and while this is downloading, So just in case that the image is not yet available, so this is gonna show this place holder in your off the actual image. So I'm gonna actually open this one with preview and know what I'm gonna do is recite this one with the just size and I'm gonna make it of the same size off the one. So that's the same size that we're using in our application, which is 55 by 55. So I'm gonna change the value and here goes, And now we have a 55 by 55 movie being foul. So let's say that so I think that it was automatic to save. So let's hope in this one again. I think it's of the same size. I'm just gonna go back to adjust size to check. Yeah, that's 55 by 55. So what I'm gonna do is simply replace what I have in my up. So let's go back. So I'm just gonna delete this one for now. I'm going to do deal it and then select to move to trash and re drag the exact same one. But this time it's gonna be with different a different within heights. Let's run again, and they shouldn't be any difference it's gonna be like a smooth transition. You're not gonna be able to see that. Actually, the image is missing and that this is being downloaded farrago, So they're all of the same size, so that's pretty cool. So the other thing that we're gonna do is this is optional. So this is only if you're like So we're gonna do that at this level. We're gonna also allow the images to be rounded. I'm just knew puts add around it corners. I'm gonna put rated. So basically, what we're gonna do is changing the Regis of the borders. So that's gonna be with cell. And I want to target the image you and that's maybe the layer. So anything riches related to the images para meters. So that's gonna be we can access this one. So with the corner with the leader, So anything So that is actually beyond to the u I view itself. So we're gonna be able to access the corner Regis parameters. So by going through the layer, so that's gonna be corner radius, and I'm gonna put this one, so that's gonna be equal to whichever value you want to apply. So that's gonna be half off the with or heights off the elements that you're getting off the elements that you're targeting in order to have a perfect circle. So whichever element that you're targeting, so that's gonna be half off the with or hide in order to have a perfect circle. And the thing that you need to do next is also to change the value, which is a 1,000,000,000 off max. Two bounds, too true. So let's do that. So this time we're gonna have rounded images inheritable. So that's another option if you'd like so either rounded or square sheets perfect. And we can navigate to the webpage of the corresponding movie that's select one with a trailer on tonight's show. 11. Downloading Movie Rating (*): Okay, So back to the OM to be a P I. So what I'd like to do to complete this tutorial is to also display the reviews. The rating. I mean, so we have this information. So which is the I d off the movie? And there is one way to actually do a query for one specific movie and display more details . So return more details about a movie. So I'm just gonna get one. So that's the same Batman query. I'm gonna pay. Sit here. So you see this section with examples I'm gonna paste here and then click search. So we have this new aquarium, but you can do so we're gonna click on it. And here is going to return. So you see that we have, like, so here that with the general response from the search meaning that we'd research using here a specific query. So this is Batman. And here we doing a query. So with the movie I D. And what it does is that this is giving us more details about So the actors writer director runtime as well rated the year. Of course. The title. But more importantly but more important, least the rating. So this is what we're gonna be using next. I'd like to also display their rating for each movie, and we're gonna be able to show that also on the cell. So with a star next to a star, So we're gonna do another query for this time returns. So the information about the rating and we're going to use the idea of the movie right here . So we're gonna do that. So let's go back. So back in the movie table, view controllers, Are we gonna go here? So we have this section, so it looks like it had not used data valid here just to remove this morning and then down the media. So we're going to go right here and here. I'm just gonna put a function which is gonna be query, review or rating. That's maybe the rating that we're going to return. So that's not gonna be like reviews reaching by users. So we're gonna have one perimeter, which is gonna be of type string and here, so we're gonna have a completion as well. And after doing the query, So basically, we're going to be able to return the reading so that's the purpose of this function. It's gonna be a type stream a year ago, so as you may expect, So that's gonna be very similar to any other query that we've made. So I'm just gonna come. So I'm just gonna simply copy from here at the top and reducing to replace with whatever we need. So I'm gonna copy from this function, which was down on media. So that was to download and display the thumbnails that's gonna be like basically, we're gonna have ah, year Well, string as well. And basically, I'm just gonna right that's gonna be I d Euro and I'm gonna form at this one. So we're gonna have, like, the same string we could see. Like you have this segment that was like starting with the, um d b a p i dot com followed by the string so followed by the segment so that with the OMG p a p i dot com followed by the i d off the movie and then the rest. So we're gonna do that next, and then we're going to do the same, which is a query. So doing a task data task, which is gonna return date, our response and error. And if this is Aaron Eel, so we're gonna be able to do first, I'm going to check if let's data, OK, we called Judita, then I'm gonna do, do catch, and I'm gonna copy that as well. From, actually, that's gonna be from here because we're gonna need to also serialized suggestions. That's gonna be about the same, um, process here. Because, of course, we're gonna need to get the value from a key. So of course we're gonna need to then update So we're going to start with that. So here is not going to data values but data. Okay, So if this is okay here, so we know that this is gonna be existing and then execute this block of code. I mean, right here for the Jew. So let's go back to the browser for a moment. So we have our query results here who MTB api I So that was on the main page and he were able. So if we take one just example here of an I d. We could do an example query using just the I am to be idea than to search. And here it was gonna give us an example of what's returned for one specific research for one movie using this fighting. So we're gonna take this so that's gonna be actually the type off euro in order to do a query for one movie in particular. So let's go back to our query review grammar rating right here. So here, we're gonna format so that your l like so And I'm just gonna need to replace actually here and use the interpellation twos. Pass. So this perimeter so that's gonna ban extract and return the value that corresponds to the idea string that we're gonna pass. So when we do so the query ratings. So we're gonna pass a value that's gonna corresponds to the idea of the movie. Then we're going to be able to then Fermat this Euro with one specific movie I D and then run the query. Based on that, what we want is to then pass the Giessen and basically so we have I'm going to create a new verbal here, so that's gonna be cold reading, and that's gonna be a type string, and this one is gonna be equal to one value that we're gonna get from this just in decline . Just gonna call this one dicks because we know that this is a dictionary. So let's go back to the browser. So what we want is to get so we see that this is the higher level. So that's just one dictionary. So we know that we are already targeting this one. So by just simply here using So this just index So we purse the Jess, um, and we want to target. So this I am to be rating keep in order to get the value of these. So we're just going to do something like, um, I'm gonna print it at first, but that's gonna be movie rating ISS. So we're gonna test that movie rating is, and then I'm going to use the interpolation, so I'm going to do just indicts and then return to buy u That corresponds to I am to be rainy, and that's gonna beat as East drink. Okay, so we're going to try that. So obviously we're gonna need to call this function from somewhere. So that's gonna be the best will be to do that from, So it looks like a heaven extra. I may have an extract. Um, purist. Think on extra records. So that's just keeps things organized. I'm just gonna So here, this is for the duke here. It's for the And then we've got to know the one do, if another one for the if normally. So maybe I didn't need to remove it. Yes. And then we have lost the data desk that I've missed the requests. So he's input request. So we started this here. Now, this is closed right here. Okay, so this is back to normal. Okay, so now we're gonna be able to call this function. So from where we can figure it, sell one after another. So we're gonna do that. Let's go back up right here. No, not right here. So here, at this level, I'm gonna do it right here, and I'm gonna do query rating, so we're gonna pass a string. So that's gonna be we want to use the movie, the idea of the movie. So that's gonna be I am DB. Well, let's operating That's type. Okay. Movie. And then I m d B or I g Remember, all movie, sell my bed. So this is where we need Okay, My bet. So this is movie cell movie selling that I am to be. This is what we need, Like, repressed this as a value in order to concoct innate. So the value of the i d off each movie and then so format these euro right here. So that's gonna be with the idea off each movie and further to that, so we're gonna be able to then return the rating strength. So this is what we're gonna use them. So let's go back here. And so here, I'm gonna write reading. And basically, instead of reading the year for each movie, we're gonna get the rating for each movie. So here, I'm going to replace the movie year with the ratings. I'm gonna put this one right here, so that's gonna keep everything in groups like first the title, then the reading. So that's gonna be right underneath. And then we recite the image. So the image you off the self, so let's see how it looks. Good. This is running. So Okay, so I've got some Steidl instead of the rating, So Yeah, of course. Yeah, I bet. So what I'm doing is first printing it my bed. So that's something that I can't movie. I'm just gonna Okay, we said rating. Yeah, year ago. So, yeah, the first time was directly read. If these is sprinting, so we know this is working fine. Movie rating is whatever. But now what we're gonna do is actually return so and then a sign, Because we did something before we actually completing this part, which was rating, which we haven't used yet. So we know that this party is working. So we're gonna take all of this and then assigned to reading year ago and then use the completion in order to pass. So the rating information and we should do that. Like, at this level I missed also to print. So just to keep things like the same way, I'm gonna prints error, localize description just in the case. Okay, so let's do that again. So this time we're gonna be able to actually read the rating. I have an extra furnaces. This time, we're gonna be able to read the rating so underneath, so as a subtitle. So right under the title of the movie as a string, I guess. Lots of foods. Okay. Escaping. Okay, and here go. Perfect. So what I'd like to do is also to change, actually the setting. So I'd like to actually use a different formats for the cells. So let's go to the main story board. You're going to see that you have different options for the sales. So you have subtitle. You can also have left detail or right detail. So I'm gonna choose this one, actually, So we're gonna need to also change the phone size for each of them because it's back to 17 . So let's try that anyway. And we're gonna out a star as well. So we're gonna have a star before the movie rating. So we're gonna add this were basically basically we're just gonna use an emoji for the storm. So let's so here you go. So now you've got the title right here, next to the thumbnail and on the right. You have the movie rating, and I'd like to, as a perfect an emoji, which is gonna be a star. So we're gonna do that next, we're gonna have a star, then also from up differently the title of this entitle. We're gonna do that next 12. Star Rating Emoji: so we're going to finish to configure. So this table view with the title and rating on basically, I'm going to look for an emoji for the store. So we're gonna look for once and just any glowing star emoji, maybe. Yeah, this one seems fine for Apple or some soon. What do they have? What? Zilla? Let's go see Another one sparkles in which, you know that's the same store science get emoji. So here it can simply copy and paste. Looks like star can do them up. Search glowing store restore David White medium Start. This one seems fine. So I'm gonna get this one copy they're ago. So I just need to copy this emoji and so back to movies Table you, controller. So I'm gonna add this one. So rights where we are actually, at this level, that's gonna be record at it here at this level. So whenever we're sign, Not really. I don't need to force typecast this one. I'm not sure so we could assign this. No, that's actually better to go at the level of where we configure the cell right here and then do something like so. So I'm gonna paste my store and then used the plus to come. Captain ate the choose the first we're gonna have the star and then the value of the reading. Okay, So the other thing that we were going to do is do format, also the title. So I'm just gonna decrease slightly for the subtitle. It's gonna be way smaller, like, 30 or even 12. We're gonna change also the color, so I'm gonna put bits, so I'm gonna put it like blue, for example. It's really arbitrary. So you can change the colors as you wish. So we're gonna test that We've got a few changes now and here ago, although this is a little bit small. So what I'm gonna jury is for the title. Well, im I'm happy with the title. Like so maybe for the reading. So we should make it a little bit bigger. And even using a bold formats bigger and then vote style, it's gonna be so my bolt, for example. Let's try that again. Correct. So it looks like some of them don't have Or maybe I think it's not available. So you have a few movies that don't have actually ratings, so I think that the way that we can change that is maybe to not put anything. So let's see, yes, like, not applicable for certain. So there's no reading like for some of them. Okay, so what we're gonna do is we can check. So whenever we do the query So here what we're gonna do is do a check. So that's gonna be if rating equals two, not make it will like So we're just gonna have puts. So we'll just need room actually this part. So we're just gonna keep this star and here, So it's not an assignment, So that's the comparison. So first, what we do is checking If writing is equal to this, to sign just a star, so that's just gonna be this. And if it's not equal to this, that this is actually so this is equal to an actual rating, we're going to get the star plus the reigning, which is gonna be then attached and assigned to the detail text labels. Let's try that again. And there was another thing that I think we should do. ISS limit actually the title to just a certain number of characters, because otherwise it overflows and it's too long. So it's gonna fit to be contained in one label. So the first thing that we could do that main of work is actually getting this one and then put this one equal to zero. Same for this one as well as we're here. And then also here, select word destroy that. Here you go. Looks like, actually, So when it this is too long. So this is actually putting this one. This is pushing. It doesn't look very nice. So we're gonna need to find also a logic to check if this is too long for a certain title. So, of course, you're always gonna need to check which type of information is returned to control how it is handled and then displayed, and this one is completely out of work. Okay, So the way to control this is I think first it's related to the side, so it seems fine. So there is the word wrap. So maybe I should make this one a little bit less, um, shorter, I guess. A shorter. So that's like this. It looks like we have actually no constraints. So doesn't play. We can actually specify any concerns for any title within a cell. So that's maybe title, and then we're gonna go here. So here, we're going to select Explicit. So in order to apply your with So maybe we could actually make this one like, shorter half of it. So that with 30 originally So I've checked Express. It's in order to have, like to be able to change the value, which is applied as a with to the label. So let's try that. So that may look too short. Maybe, but we're gonna play with the values. Here it goes, So that's it will be better. Looks like maybe with some of them pertinent. And the other thing I wanted to do is, for now, this is maybe too large, just gonna decrease slightly the size of the title. Let's see, that helps a little bit, and that could be better. Like here that was completely pushed, like it was like one on top of each other. So that's better. So this one doesn't seem to have the image, and we should be able to apply an image. So if there is known, so I should be able to check that if there's no image and actually, it's just taking time. Okay? It's just the download time, which is that text? Longer. Although we had a placeholder, so sometimes it smell a bit tricky. And here looks like we have to. For some reason, that is strange. Here we may have something. It's activated. Skates beat three. This one is so eight. And also another option will be to go back to subtitles. So you have the options with left detail. Although it doesn't include an image. You for this one, we're gonna try against the title and normally the best way to proceed east to create a custom so so accustom cell that's gonna love to have more control on the size of the label , the images and also with the subtitles. And you can add as many views as you would like. So you really configure the cell as you'd like, So we're gonna leave it as is. So we have the title and the rating right here that we can make bigger. I like to make it bigger. Here you go. And actually, I'm gonna drink bolt because now we have enough room. And if you'd like to have a default, some default texts. So what we can do? You can actually do it from here. So maybe we can put something like zero for now. So let's go back to the movie Stable view controller. We're gonna get this store just so we don't get nothing, You know, sometimes because it takes a little bit longer to download. Let's go back to the storyboard, and then we're gonna add also this star right here. So that's not gonna look weird. And also, I think, ah, if I go back to now, looks like we don't have the image anymore A year ago, so just so we don't have nothing. So while this is downloading, so we're gonna have, like, placeholders contents. So first, the star and the rating, which is gonna be zero anyway, there's nothing for the moment. And also an image placeholder. So that's gonna look way better the time for you. See here for now, this is zero. I think that Okay, that may take some time to download here ago. So now we have it. So the time for it to download we're just gonna put some placeholders. So that's way better now, So I'm gonna also customize here, Let's go back true here. I'm gonna add a title for movies. And here we know that we're able to diss with title of each movie. So when we selected, I'm gonna change also the color of the borough navigation bar. So I'm gonna do it from here. And that's gonna be black. And then also the color of the title, which is gonna be white. Let's try that again. So now that should be final care ago. The following trailer is rated H for honest thought. It would be easy to turn bad man into a cool video game for 20 years.