 to cover on a single day. And depending on the pace of the class, we will see how fast we can go or how slow we can go. It is okay if we miss certain things because we won't have any full day workshop but what we are going to do is whatever is left over from today's lesson, we will probably do as part of the study group like one lesson should be enough. I think we will probably won't be able to touch upon a lot of the things that I put towards the end but let's see how fast we can go. Because one of the things that I haven't covered in the last class is a lot of the basic concepts like we read some examples, we tried the story board, we jumped right away to building apps but there are a lot of concepts underneath that we kind of skip through happily, we kind of need to go through especially if you haven't done iOS programming before. So I will just start with some very basics and those of you who know these things already, this is going to be kind of a recap for you. So we will start with MBC. I didn't talk about MBC at all in the last lesson. So iOS programming is based on this concept of model view controller. This is basically a design pattern. Apple recommends MBC. There are other people using some other design patterns like MVM is another thing is very popular. That's something we have been using in PayPal. There are certain advantages of MVM over MBC but MBC is what we are going to kind of look into in this workshop or in this lesson. There are three different components right, model, view and controller. View is basically the user interface, the UI where user interacts with, user enters some input or taps a button or something and model is where you kind of deal with your data. It's not necessarily just with data. You can have different objects that represent your data. You can have logics to kind of validate that data. So that can be part of a model and controller is kind of the bridge in between. So if you see on your view user does something, user performs an action, either enters a text in the text field or is a taps on a button and the controller is going to update the view or is going to do something in response to that action. On the model side, so controller is like not always but sometimes when user interacts on the view it comes to a controller and controller might need to update the model. If I will give an example let's say you have the address book app on your iPhone and user is going to enter an address and you probably need to update the data on a model and once that is done model kind of notifies back to the controller. So that is in general the thing about model view controller. If you look into the application that we did SGFood, we had basically we created this screen or we built this screen. Now what are views here or what is a view component here on this screen? Well literally everything is part of your view here. You have a navigation bar, you have a title which is probably a label, you have a UI button, you have a label where you display the text, you have a UI view. So everything that you see here is part of your view and what about the controllers? So the thing that we had and have been interacting with is the view controller or UI view controller that is our controller. So it basically listen to various events and perform certain tasks. You are tapped on a button, you find which button is tapped from the tags, you know navigate to detail screens, pass parameters to other screens that is all the logic that you are handling in the controller. And model, so you haven't touched upon model in the last lesson but let's assume we can have potentially a class separately my SGFood class, you can have properties of that model, these things can be properties of that model like name, image, description, tag, you can potentially have something like like by as part of the model. And you can have various methods to kind of do you know create, delete or other operations on the model. I will go ahead with some other concepts and you know before jumping into some demo. So one of the things that we did in last lesson and we looked into was this method called view deed load which basically gets triggered when your view finishes loading. But there are certain other methods which doesn't come by default when you create a view controller class. So you are going to kind of try this out today and see how it works, what is the life cycle. So the thing is that view deed load gets triggered when your view finishes loading but there might be certain cases where you want to do something when the view appears or when the view disappears. You might need to do additional kind of setup on your screen or you might need to reset certain properties when the view appears or view disappears. So the important thing to note here is these four methods you will probably need to kind of you will interact with maybe view did appear, view did disappear. View will appear if you start from the disappear the circle. First the method gets triggered is view will appear. It tells your code that hey you have an opportunity to do something because your view is going to get appear. Then after that the method that is going to get triggered is view did appear that is when your view appeared. Similarly for the disappear cycle you will have view will disappear and view did disappear. We will see how it works. Let me create a new project. I will just go ahead with the same single view as project. Let's call it view life cycle. I am not going to do anything with the story board because the thing that you are interested to look into is how this method you know how these methods get triggered and in what order. You can do the disappear part later. Let us say I have these three methods. View did load we already had and I just added these two. Now if you see here we have this super view did load. We kind of never looked into it. I will talk about base class and super class in a bit. The thing is that this is the view did load is kind of a call back method you are implementing in view control class and you need to make sure the super class implementation is working fine. We need to do same thing for view will appear. Again this syntax will look into the syntax of how to pass parameters into methods. We are going to cover today and I am just going to do this. But what I am going to do is I am going to print certain message like view did load and we will see how it is going to work. If you see your view did load kind of gets triggered first then you will have view will appear that gets triggered then you have view did appear. Now if I remove this view will appear that still works fine. You have another opportunity to do something in the view did appear. So if the view did load still gets triggered and then the view did appear gets triggered. Now you might think like what is the advantage of having view did appear when we already have view did load. We will see in a while what is the advantage. For example, let me change this storyboard to disable auto layout. 5.5 is for success plus. I am just going to go ahead with navigation controller. Same thing that we did in the last class where I am going to change this order and make navigation controller as the initial view controller. So my view controller is going to be the root view controller of navigation controller. So you have this. I just want to add one more view controller to this. I just dragged it just for understanding my first view controller is going to be let us say orange color the next one is going to be the blue color. I am going to put a button and I am going to create a segue push segue. So all this should kind of look familiar to you. Now let us see what happens. I am not going to create a separate class for this second view controller is just for understanding let us see what happens. So I have all these three methods that I get triggered when the first time we have this initial view and when we go I do not have the disappear methods already here yet. But then if I come back again what happens? The view did load does not get triggered. Why? Because the view did this controller is already being initialized. So you will have only one time to execute the code that you have in view did load. If you want certain things to kind of to be done every time when you come to the screen then you need to execute them either in view will appear or view did appear. So similarly let us say we execute we implement the view did disappear part and view will disappear part. So you implemented all five methods starting from view did load to all the other four. So you have these three that get triggered when the view is loading and when you go to the next screen that time the disappear method gets called because your initial view controller initial view is getting disappeared and when you come back your view will appear and view did appear gets triggered. Now before I move to the next section try this out try to implement this five methods and see the order how it works. You can probably you know try it a little bit more creative you can change the color of your view on one of them in one of the methods get called. I will give you five minutes to try this then I will move to the next part. So you can try that part out when we jump into the hands on session you know after explaining little bit more things. But this is a diagram I want to kind of I want you guys to look into like we talked about model view controller right and then in this diagram you have certain system objects you have certain custom objects that you create and you have certain objects that are either been created by system or custom. So let us talk look into the controller part right. Your application the entry point to application if you look into the sample code is actually this class app delegate dot swift. So this is the entry point of your application earlier in objective C we had this main dot m kind of class and main dot m file very the main function is the entry point. But what this does is this line which is at UI application main it creates your app delegate and it kind of creates a UI application object. Just imagine this class is responsible for listening different event loops in your application. So what does that mean? So basically let us say your application is running and you received a phone call let us say your application is a game and you received a phone call. Now it is going to annoy users if you just kind of exit the app and user are going to start again from beginning to play the game it is going to really annoy the users. So you have certain methods here that gives you opportunity to save the state of your applications or save the state of your game. So like you have this method application did enter background and you have this method we will enter foreground. So did enter background is like basically application entered into the background mode you can save certain state that you want to kind of save and when the application comes to the foreground you retrieve those states and then redraw the view or the screen so that user can start using the application from where it paused or ended. Now on the viewer side we have been interacting with directly storyboard and we know in the storyboard we have basically the view controller. View controller is nothing but as we know that is a controller but each view controller has a view part where we draw certain things. So this center thing of the view controller is the view where we put other view components or draw other view components but what we do not see here is this thing called UI window. So in your application delegate dot swept you have one property called window. So basically each application have a window and you basically draw your view or UI objects on the window. Imagine the window just like a canvas and then you are drawing something on top of a canvas. Now this is really useful because sometimes Apple does not provide certain methods for certain particular view components but if you understand the fundamentals of how window works and how view works you can get past that and you can create whatever you want because at the end everything is a view and you are drawing every view on top of a window. Even if Apple does not provide certain API or certain method for a particular type of view you know that you can still draw something on top of window. We will see certain examples you know what I mean and what are the methods that Apple does not provide and you can still kind of get around with it. Now all these methods like if you delete all these the application is going to run normally just that you would not have those opportunities to run the certain piece of code that you want to run when this event happen. So that is about AppDelegate. Now these are the various states that you have. Now this is one of the interview questions that many people ask when you are going for an iOS interview how many states you have in your application, what are the different states and how they behave. So not running is basically either the application is not launched or is being killed, is basically is not running. And in the foreground mode you have the inactive and active state. Inactive means it is not receiving any event at all. It is kind of ideal. And then the application stage in an inactive stage just for a small moment before it kind of transitions to another application. Otherwise it will always be kind of active if it is on a foreground mode. So let us say you have you know certain applications have this map view you tap on the map and it goes to the map application right. So this small moment when the application remains idle that is kind of on the inactive state and active is when it is on the foreground it is receiving event from the user that is the active state. Background means it is in the background but it is executing certain code. Like a lot of fitness application they run in the background and they track your location. Like you are running, they track your location and they later plot it on a map. So those kind of you know that can be an example of running in the background mode. Music applications you kind of put them in the background mode you still listen to the music. So that is in the background state. Suspended means it is in the background and it is not executing any code. So yeah. So these are the kind of five states of your application. Now look into this file info.plist which is also a very kind of important file. You can add so plist stands for property list it is similar to XML and if you actually open it this file this looks again XML file. So this looks like XML file and then but what you can do in this file is quite a lot of useful things. First of all let's say you created a project by certain name and later you decide that hey I want to change the name of my application under the display name of my application. And changing the name here is possible but then you have a lot of directory structure a lot of other things that is going to get screwed up if you change the project name itself. You have the version controlling system you know where you store files and everything that is going to mess up if you just change the project name. The easiest way is to just change this thing called bundle name. You just say I have a view life cycle as an example I just change this name to hello. Now with this I have this name change to hello right. There are certain other additional things like this application by default it is okay telling that it is going to run in portrait mode in this mode and it is going to run in landscape. We haven't supported landscape here with auto layout but let's say you want to lock only to portrait and then the thing you can do is these are the two lines you can just delete from the supported orientations. Now it is going to lock your application to portrait. So irrespective of how you move the device it is going to just stay there and it is not going to change the view orientations. We will see some of the other properties but mainly if you can see it tells things like your main storyboard file is going to be main because your main storyboard is main or storyboard. If you want to change that to something else you can change it here and then launch screen is basically launch screen if again if you want to change that you can change it here. All this background applications that you need to run you can provide what kind of access you need from user and how it is going to run on this file. With this we are going to come to this important concept called delegate which is probably the most important concept of iOS programming. It is very different from how things are being done in other programming languages. So delegate just by definition if you see it tells that it is an object that acts on behalf of or it coordinates with another object. Imagine like forget about programming in concept delegate in general. Let us say you say in conferences you see delegates. Basically people who represent their company basically they do certain things on behalf of their company. So basically that is the concept of delegate in layman's term but let us see how it kind of fits together with our applications and with all the components that we have. So basically you have two different type of objects. One is the delegating object and then you have a custom object. So the delegating object gives a reference to the delegate. Again I will go through an example and I will explain this more in detail but just see what are the things that are happening. So basically the delegating object gives a reference to the delegate and it sends a message to the delegate at appropriate time. It basically sends a message at certain point of time and it tells the delegate object that something happened or something is going to happen. For example if you look into the methods that we had like view did load that is one of the delegate methods that is telling your view controller that your view is going to appear or view has finished loading. So basically those are the moment for your application or your code to run certain things. So it tells your delegate about an event that the delegating object is about to handle or just handled and what your custom object or the delegate object is going to do it responds to that event either by updating the appearance of the view or the state of your application or either it updates the delegate object or the delegating object. Now it is little confusing just by listening to the terms but let's see this in action. So if you remember we created a simple application in the first class which was basically we had a text field then we had a label and when it tapped on the label it updated the text of the you know when you tapped on the button it updated the text of the label right. They are going to do the same thing but with delegate. So I am going to create a single view application. I am just going to name it as update text or something. I am going to stick to 4.7 for iPhone 6, disable auto layout. I plan to actually cover auto layout today but we have so many things to cover so I won't be able to cover auto layout. So I will use a text field I will have a label here. Now this time I won't have any button. So what I mean to do is as I type on the text field I want the label to get updated automatically. This is where we are going to use the delegate. So there is this term called confirming to a delegate or protocol. The way you do it is basically you put a comma and then give the name of the delegate and you can put comma and just kind of confirm to other delegates also. So for our case we are going to use or confirm to a text field delegate. So I just put UI text field delegate. What I mean to do is I don't need a reference to text field. All I need to is just create or use an IV outlet connection for the label because label is what we are going to update. Let's call it my label. Now if you open the library utility section the last one is basically your connection inspector. So if you tap text field when there is this thing called delegate that comes up here. There is this circle you click on that and drag it to your view controller. So that is one way of telling your code that your view controller is going to have is basically the delegate of your text field. Or if you don't want to do that then you need to have a reference to the text field and then you need to do text field or delegate equals to self. We will see that method also. But we just already told our system that this class is our delegate for the text field and now there is a method called text field. There is various delegate methods here that gets triggered at certain point of time. If you see text field did begin editing is something that will get triggered when you start typing on the text field. But what we are more interested in is this method which is basically it is going to get triggered every time something changes on the text field. Let's just print the text that is getting changed. So this replacement string, this string and then because it expects a return value you need to return true. Again the syntax here tells that the return type is a Boolean. We will look into this in the methods section. But with this what is going to happen is as in when I type something on the text field it is going to print that character. If you see as in when I am typing it is just printing that individual character here. But we are not much interested in this character itself. This might be interesting for another application. But for this particular application what we are interested in is receiving the event when the text changes and we move for sure that this is a method that gets triggered whenever something is changing on the text field. Now here we can do. So your application basically this delegate method gets triggered every time something changes on the text field and on each of those moments you are basically updating the text of the label with the text of the text field. So as in when I type it is updating the label. So coming back to the slide let us see how that fits together. So we had again two objects. One is the delegating object. Here we have the text field as the delegating object and we had that delegate which is our controller. And the delegating object gives a reference to the delegate. Usually you can do it by text field or delegate equals to self or the way we did it is by writing the link from the storyboard but basically you have a reference to the delegate. Then basically you send a message to the delegate when the text is being updated and it tells the delegate the text is being changed on the text field by this method. So you have the have a moment to kind of do whatever you want to do by implementing this method and you responded by updating the label. So I will show you another thing before you kind of jump into implementing this. Let us say I do not want to do this. Let us say I just want to I am implementing this text field did begin editing which basically this method is going to get triggered as in when you start typing something on the text field. Now as in when I just clicked here it logged the thing here. Now is it interesting you know is it going to help us anyway in the application? It might imagine let us say you have the moment you tap on the text field in general on the actual application the keyboard is going to come up and you might want to change the view and you want to kind of hide certain section of your view or you want to represent you know sometimes when you type it shows in auto complete on the bottom. So those are the things you can kind of bring bring up as in when you just start typing on the text field. So with that give it a try because the same thing that I did with the text field and the label example. Not of the view or not of the label so you need to drag it to the yellow section the view controller here that is how you link and then let me make it and this is how we kind of confirm to the delegate by comma and UI text field delegate and this is the while connecting right don't drag to don't drag to the view you need to drag it to the view controller which is on the top yellow section and you can confirm by again the linking is so so view controller and not view. I'm going to use the same example that I have here you can create a new project if you want I'll just put a label you can put an image view if you want and then I have a speaker view usually speaker views are clipped to bottom but however you might see certain applications where you can have it in the middle but it doesn't really look nice to have it in the middle. So if this is the only thing that you are going to do this pick and display an image or update the text it's better to put it at the bottom and then I'm going to confirm to this delegate there are two things one is UI picker view delegate and another one is UI picker view data source. Now you need to kind of make yourself familiar with these two things underneath they both are something called protocol or delegate as you kind of can imagine but data source is something that supplies data to your the component that you're going to implement and delegate is something that is related to the behavior of that particular component. So for in this case we can use the data source to load the picker view whereas when you change something it is going to you know implement one of the methods from the delegate. So for this case we need to use both UI picker view data source and UI picker view delegate right. Now let's not implement the delegate yet what we are going to do is let me just just use an array for the name of the countries. Let's put some names there. Now later after this example we are going to modify the SG food application to have a table view instead of the buttons because as I was mentioning that buttons are kind of a really bad way to build apps and we did it for learning but there is this thing called number of row in components if you start picker view and there's number of row in components basically this tells how many rows the picker view will have and for our case we'll just have as many rows we need for the list of countries. We can just reduce the number of rows you can have like five or three or whatever but for this case I'm just going to have country names dot count is going to return me the number of elements this particular array has and that that is going to be our number of rows and there is another thing called number of components. We'll see what it means but for our case we'll just use one component so he's just written one what happened the autocomplete is broken let me just quit and restart this okay so picker view delegate and there is another method which is title for row it is going to display the text for each row and I'm just going to return and it expects a string I'm just going to return an element from the array and it has one parameter which is row it is going to give the row number so it's starting from 0 it is going to give me 0 1 2 3 whatever but with this after I length my picker view I'm going to have both data source and delegate right I have this picker view at the bottom try this first then we'll see how to change the change the label. Almost everything except the method that will get triggered when you change the or you pick something from the picker view so to update the label what I need to do is and it to create an outlet for that I just call it my label there is another delegate method which is did select row and that gets triggered when you change something or you select something and the only thing we need to do here is my label dot text is this one so this is going to give the selected element because this is this argument row which is giving the row of the selected row and you can just fetch the element by row and as you change it is going to update that similarly if you let's say you have an image array you can do the same thing you just pick an image and display it now we are going to look into table view which is again one of the most used component on iOS you'll see a kind of really a lot of table view examples like table view and collection view these are the two most used components like Facebook's news feed is table view if you see YouTube the list of videos that they saw that is table view and even on address book the list of context that is table view so it's like a lot of apps are using table Instagram is table to trace table view so everything is kind of table view if you see we're going to update the ASG food app and modify it to table view format first of all create a new project instead of modifying this because for me it is kind of I'm just modifying the existing app but you at least have or you at least take a backup of the existing apps so that you have multiple apps that you kind of have worked on I'm going to delete all these things that I did and instead I'm going to put a table view now there is something called table view controller and table view now table view controller cannot have anything other than table view on that controller whereas table view can have a table view and you can have other view components part of that view I'm going to use that here so I'm going to take it slowly step by step we're going to create a basic table view first then we see how to customize the look and feel of table view and then on tap of the row on how to go to the next screen if you have static cells you can use a quiz but because we are going to have dynamic cells based on dynamic elements or dynamic data we are not going to use segue here rather than we use the delegate method so we had this method prepared for segue I'm just going to comment this out because we don't need it but similar to the picker view example we need a table view delegate and we need a table view data source right it is going to give me warning or error because I have not implemented all the methods that are required as part of these two things but let's let's come back here first we are just going to load let's say few we're going to create few cells with and just going to load some title so I just create something called this prototype I just I'm just going to increase this by one so it is going to give me one prototype cells now if you see the table view is dynamic prototypes and static cells if you use static cells you can actually they won't allow static cells on normal view controller but if you use table view controller you can have static cells and let's say you just want to display a set of static data then it is fine to use static cells but I'm going to use this dynamic prototype cells and increase this by one this is my one cell and this is the view of the cell the content view and whatever I'm going to put here it is going to be each cell each cell will have that particular look and feel so if you see the style itself has custom basic and there are a few different types I'm going to choose basic to start with if I choose basic it is going to display only a title right and if I click on the sale there are few bunch of few other properties one of them is accessory I'm going to choose let's say disclosure indicator then the right arrow kind of comes in you can kind of modify to display a few other things like some certain view table view has like it allows you to choose only one thing you can you need a check mark for that you can use check mark or if you want details you can have this eye icon but the most common one is this one the right arrow again clicking on the table view I'll go to the the connection inspector and I'm going to connect this delegate and data source why come back to my view controller I'm going to implement two methods one is table view number of rows in section let's say hard coded for now I'm not going to display actually less let's display this food names so this table view is going to have eight rows because our array has eight elements similarly there is a method called number of sections like we did on the picker view but over here it is optional so by default it is one so you'll have one section we'll see what what what is going to happen if you have will have more than one section but here we'll just use number of sections which is going to return eight elements and then there is this thing called cell for row at index path and when we need to return a cell from this method I'm just going to use cell there is this method called DQ reusable cell with identifier what it does is once a particular cell is being created it is going to reuse that cell it is only going to change the data I've needed but once the cell is being created it is going to reuse that so that you don't have to create multiple objects because each time you create a new object it is going to take some memory and on you know things like on on a smartphone where the memory is limited you need to reuse a lot of things so that is why the DQ reusable with cell identifier it takes a reusable identifier and we can specify the identifier here if I tap on the cell and go to the attribute inspector then there is this identifier section I can give whatever name I want string I want I can just name it as food cell identifier or something it is just a string that I'm going to use that here and because it is a default cell type I'm just going to do cell dot text label dot text because it is going to display title I can just do food names and then this thing has got something called index path and now index path has a row property and a section property if we are going to use multiple section it is going to give which section we are in but in this case we are interested only in the row so you can just do index path dot row which is going to give us the row number and from the array we are going to fetch that element and we are going to display in the title it is asking because this thing is an optional it is asking to force unwrap again you can use on the guard let you as we saw or if let but with this it has a table it like sometimes when you kind of make it really small the lines get disappeared because of but this thing called D pixelate but usually it should on the actual device it should look like this and yeah basically that's it it can be clickable but we are not handling that click part yet but try that first just try to display a title and create a table view the example of the kind of section table view is going to be on this like this is a single table view code whereas if you see you have multiple sections here and like each section can have different rows so like the first section here I have two rows and here there are different number of rows so this is an example of you know multiple sections but for our case we are just using what is that we are using this there are a bunch of things that we did here just try it out even to take a break as soon as the food is here but we are going to continue and modify this you know after lunch and we'll see how it works first of all we'll see how to put an image here and how to customize this view yeah kind of got some feedback that things are literally fast as in the pace I'm moving in is little fast anyway the goal here is not to complete all the things that I've put in the agenda it is to kind of understand whatever we are doing right then once you have the confidence you can build or learn on top of those things right and as I was saying we might not be able to finish everything that I put in the agenda today and we'll probably continue this in one of the Swift study group lesson that we usually have in the evenings maybe we just need one or two sessions to kind of wrap the basic part but I'll go really slow here for next few hours that you have today and I'll spend a lot of time today on the table view because as I was mentioning table view is one of the important concept and there's so many things really in the table view that you can do so again we'll go step you know step by step and then we will have hands-on exercises but feel free to grab anyone of us if you're stuck because make sure you kind of understand the basic concepts of this table view delegate methods and all the normal concepts so I assume that you have at least this thing done so which is like the simple table view with all the sales populated with some string right I'm going to do something here now first thing is like we looked into number of rows in section which is basically we are going to we are printing this array count which is going to display eight rows there is another thing which we did in the picker view example which is number of sections let's see what it does and as I was mentioning in the settings app right you have few sections here like for example here we have four sections let's say this same app we want to modify a little bit on top we want to display this SG food right the list of food and at the bottom you want to display a few of the popular restaurants that we kind of like to go right so you basically have two sections and then I'm going to number of sections I just return to here because I'm going to have two sections you can pick it from an area or whatever from a variable or something but let's say I just I am really running out of restaurant names something right so this is three now here in the number of rows we don't want five rows in the second section we want three rows so what you can do is there is this parameter section we can just condition on that one so what you can do is if section is zero which means the first section we are going to return five else I think if I put else here it'll come clean let me see yeah because that's fine so now we will have two sections and the first section is going to be we're going to have five rows the second section is going to have three rows here also similar to index part dot row we have index part dot section which gives us the section number again if index part dot section is zero that means for the first section we are going to pick the data from the food names array else we are going to pick the data from the restaurant names array so with this if I run on the app it's fine the restaurant names are getting printed but hey why does it kind of looks like it is part of the same table right there's this thing there is a property here if you tap on the table view there is this tile body for this plane we need to change it to grouped with grouped we are going to have two different sections the first section is going to display the list of foods the second one is going to display list of restaurants so that is about section and the group table view try this out before we move ahead to the next part so okay well some of you are asking you know what is going to happen when you have more sections right how the condition is going to work it's basically the index part dot row and section they they are like an array so it's like let's say you have three sections you can put if section is zero this else if section is one you do something else you just put the restaurant names let's say the second one I don't know you just put you just have three rows just for you know example and for the second section I'm going to have let's say I just print hello and the row number right so the first one is going to give me the number of rows based on the food names array the second section is going to give me three irrespective of you know we don't have any array here the third one is going to give me three also because the restaurant names array has three elements while displaying the cells the first one is going to print the name of the foods second one is going to you know display hello and the row number third one is going to display the restaurant names and if you see basically we have three sections here now we're going to modify this you can you can do something like let's say if you choose the basic type there's a subtitle also which is basically that has title and subtitle and the way you kind of get the subtitle is let me just put subtitle um there's a details detail text label and you can just do text let me just put a hard coded string for all the rows irrespective of which section they are so and I have the subtitle for all the rows but usually if you see this is very kind of it is limiting our you know creativity to just whatever design they have again I'm going to comment this out you can keep it if you want I'll just go back to the food's name I'm going to and I'll just because I don't have any section anymore you can keep your code whatever you have done or you can create a new project if you want so what I'm going to do is I'm going to modify this first of all instead of the style being you know from one of these I will just select custom and I can actually increase the row height here right let's say I choose something like 80 which is um little bit bigger space and I use an image view I adjust it kind of make it a square so so I have a I have an image view and then I'll use a label right but it is not going to work out of the box what do you need is because this is a custom cell we need to create a custom um we need to create a class for the custom cell and the way we're going to do is I will right click new file you select co-cuter's class and make it a subclass of ui table view cell you know if it's not there by default you can just type ui table view cell and I can call it custom food table view cell you can call it whatever you want I'm not going to create a separate jib file because um this is again if you want to create a separate user interface you know you create a user interface for this separately outside of your storyboard then you can click that one but we're not going to do it because we already have the thing um in our storyboard we created um we created here so what are we going to just do is we just use this custom um cell and over here I'll click on myself if it's not clickable here let's click here go to the identity inspector and this is why I put my class which is custom table view cell so I have told this storyboard that for this cell I'm going to use my custom um cell class now I need to create outlets for this too one for the image view and another one for the label so that I can modify them um in my code go to the assistant editor view by default it will have a view controller here but you can if you go to automatic you can choose here if it doesn't show up sometimes because of whatever xcode issues are involved you can go to the manual and manually found a you know find a class that you want to pick but automatically it should show the cell along with your view controller if you select that you can control drag and um can have food image view food title label right I'll come back to my view controller now this doesn't make any sense anymore you know anymore because we are going to use our custom class the way we are going to do it this cell is this this code still remains same just that we need to type classic to custom um table view cell so that we'll have the properties um available then you can do cell dot uh food title label dot text and for the title we can just um use this similarly we can do tell food image view dot image because I think for this I already have the image array which is from the previous example I can just do EY image named if I just put it in a separate constant food image name index path dot row so what I did here is I have the food image names array index path dot row is going to give me the the row number and based on the row number I'm going to fetch the image and I'm going to just set the image um here something wrong while I was linking food image I by mistake linked the whole cell um that's that's why it was giving some error click on the image if that doesn't work what you can do is um no if that doesn't work you can directly do like a food image view you can just change it to EY image view here and then you can um link from here you have the food image view you can just did I select oh this is a view no is it let me delete it and put another so this is connected and so with this I will have a custom um cell and I'll have the image the thumbnail image and the title of the food so there are a few things I I did just to recap I first of all instead of the so I select selected the table cell instead of the default types I selected custom I increased the row height there are few ways you can increase the row height if you tap on the table view you can go to this section which is the size inspector and you can increase the row height here by providing a value or you can just drag it here until you find a you know find the size that you are interested in when I put an image view and label I created a custom cell which is of UI table view cell and then I created IB outlet for these two and in my view controller what I did is I just typecasted this to custom food table view cell so that I'll have access to the properties of that class so I saved the title labels text and the image for the image view so try this I'll give you I'll give you half an hour you can be more creative you can have another description label if you want you can put whatever you want I will just put them side by side this part as well as the custom table visa so I think if you have downloaded the previous one but download this this project will probably go through this after one hour or so after finishing some of the table mister but download and this this project so moving ahead with the table view example right now you want to link it to the detail screen there are two ways to do it one is the segue approach and the other one is the delegate method you can use whatever method you want I'll show you first how to do it segue but this is going to be slightly different from the way we did for buttons because for buttons we had a reference to the tags here we need to pass the index so that you can identify which cell has been tapped so similar you can just control drag from the cell to this with this actually let's try it first so the the push is working just that um we need a reference for the for the cell and we know this is the method that we need to use for all the all the work the preparation work I'll just implement that prepare for segue but over here to find the index path or the index we need a reference to the table view so that is why we can create a outlet for the table view I'm going to control drag I just call it let's call it my so I have a reference to the table view so I have this table view here and in the prepare for segue to find the index path I can do there's this thing called index path for cell method which you can call on um the table view and the sender here is nothing but the cell the sender usually is the thing that is triggering the um transition this um so for the button it used to be the button but for the cell it is the cell itself so you can just put sender here so this is going to give us the index path if it's complaining then you can just to just type us it to your table view cell you can you can um do it outside just to make it more readable you can just to table view cell is this and then your index path is going to be this once you have the index path I think we need to force and app and you use all the if let or guard let here instead of force and mapping but we have the index path here and you can reuse this code that we wrote earlier for the destination view controller but instead of tag index we will just use index path dot probe so that for that particular yep so this will take you to the uh details view and it will set the elements and description properly so instead of buttons we now used um the table view cell and we use the segue so this is one one way of doing things you try it out first I'll give you 10 to 15 minutes but then we'll see how else we can do it using the delegate method which is also kind of interesting and it will give you a little bit more uh flexibility also so move ahead with just last one piece for the table view and then we'll see something else I'm going to comment this code out because we are not going to use segue for the next section and I'm going to delete the segue also really let me you can keep in your project and you can just take it back up or something um the thing that I want to talk about next is uh there is this method called did select row at index path which basically gets triggered every time you select a row and from from this you can also push a view controller and pass certain data to the destination view controller but it's going to work slightly differently as you see we don't have any link between the destination and the source view controller here on the storyboard this is kind of um hanging on its own um but what I want to do is if I click on the destination view controller and I go to the um identity inspector there's this storyboard id I usually keep the class name um as kind of the storyboard id you can keep whatever you want but the thing is that it needs to be unique I usually keep the class name because usually the class name is unique in your project so it kind of saves me some time to think about what I need to give my storyboard id but it's actually a string that you can put right so here if you see the code that we had um in the prepare for segue to find the destination view controller we use the segue or destination view controller whereas indeed select the first advantage is that the index path is there you don't need to kind of uh query for the index path the index path is there already but you need to find the destination uh view controller so I'll just um there's this method called instantiate view controller with identifier that you can call on storyboard and storyboard is available to all your view controller that take part in the storyboard um and you just need to pass the same identifier as string then you will have access to the destination um view controller and I'm going to copy again these three line paste it here which is basically going to set the properties uh for the destination view controller and I just need to do one more thing which is need to typecast it we need to manually push the destination view controller on on the self dot navigation controller we just to push view controller and it takes a view controller as one of the parameters I will do destination view controller here and animated is a property which takes a boolean value you can uh do true or false if you true say true then it is going to animate if you're going to um do false then it is not going to animate with this code it is going to walk the same way but without segue it's basically the same thing is happening just that we are pushing it through code instead of using segue um the advantage here is that um you will have the index path available to you um and irrespective of how many sections you have you'll have the index path and then um you'll have more control here um if you do it is in delegate but it is up to you you know the uh you know both the ways whichever you want to select um you can select give it a try I'll just give you five minutes for this one then we'll move to the next section you can't directly modify a view component from the source controller you need to pass a string then update the label or image um so some of the moving ahead we'll see some of the hoop concepts just to um and a recap for those who know and for those who don't know can kind of know what is a class and what is an object and I will say how we work with class and objects and methods and Swift right um this is the Wikipedia definition um it's like the class is something that will have an state or values and it will have some implementations of behavior right uh but in general it is something that you can group logically or physically that you can think about it has certain state and behaviors it changes its um state or behavior um when user instruct instructs or a program instructs so the behavior of the state we basically call them as properties um the way they change the state or behavior we basically use methods to do that object basically is an instant of class um it will have the same behavior as of its class and it will um have uh it'll you know have the it'll also change state and behavior with the methods okay so who hasn't seen this movie so let's let's call it as a minion class it has properties like minion class has properties and methods you know let's talk about the properties like all of them have eyes some have two some have like one they like bananas um let's say they work in different speeds so these are various properties if you can think about um properties with integer Boolean and float um and methods okay let's say they they can make move they can dance or sing they can raise hands so these are these are basically about the properties and methods of your minion class now uh they have all different type of names now each of this minion is an instance or an object if you can say they will have the same property they will have number of eyes they will uh you know uh have uh methods from the class um that they will have instance method they will they will react to but what about this guy can we call it as part of this minion class probably not because he is first of all he has some different properties we can probably tell the minion as class and then they can kind of have a base class um which is inheriting certain properties from the super class but they will have um they may have other properties as well talking about iOS right and uh thanks to Kail I'm using some of his slides here um UI view it has properties like a lot of time when we create a certain UI component by dragging and dropping on storyboard we are basically putting a frame or we are actually asking this view component to be displayed in a particular rectangle or a frame and it has frame as property it has properties like background colors width and height um and it has methods like add sub view send sub view to back um bring sub view to front we haven't used these methods but UI view basically has these methods where let's say you have a sub view you put on on top of a view and you want the sub view for whatever reason to be back of the stack then you can you know do send sub view to back or you want to bring a sub view to the front you can do bring sub view to the front um this is kind of the the if you see in the UI kit framework this is the super common like class it is the it is the best class for many of the components that we use like UI labor table view um you know collection view everything kind of it comes from UI view UI label also it has if you say it has frame it has background color but it has many other properties it has text font text color which probably normal UI views don't have and in terms of methods they it also kind of respond to the same methods same with UI image view it has the frame background color but it has additional properties um for the image view same with other views also but if you see um this is kind of everything that we work with in the view component so far label or button um or you know image view um we haven't worked with collection view but table view everything is come kind of from UI view now in Swift although we haven't really created a custom class on our own yet but you start with this keyword class with lowercase and then you give the class name usually class name starts with uppercase and your object names or variable names start with lowercase so this is how basically you implement a class um in Swift it can have uh different variables and it has an um init method which will set these values or properties um when you initialize this class your init method can be um you can have your custom init method where you can pass additional parameters and these parameters can be used to set the properties so let me let me show you what i mean by these two i'm going to um it want to open that i'm going to delete this so this is my my class where um i have certain properties and i have the init method what happens if i don't have the init method it is going to complain because it tells that you have certain variables which you are not assigning any values to if i do or you know assign some values it is not going to complain anymore because i have all the um properties that has a certain value but if i don't have something like this then i need an init method so yeah it is a constructor so in this slide as you see we have some additional parameters that we're passing to the init method but to create an object basically to create an instance of a class you basically do class name and if you don't have any separate init method or custom init method you just put these two brackets moon brackets and then that will initialize or create an object and that is exactly what we're going to do here so we created an instance of our class here and we we are trying to access a property now to set the set a property you can use dot um you know notation as well as to get the values also you can use the dot operators so what happens let's say if i use this instead of this is not going to work because my init method is no longer there i need to pass certain values here to my init method and i'm going to do it like let's say i pass certain value right and method on the other hand like this for init method we don't need any any keyword to start with but in general if you want to create a function function is a method and function are kind of quite similar you call the method when it is inside a class otherwise if it's just not part of a class you can call them as you know function you start with this keyword funk and then some function name if you don't have any you don't want any value to be passed or you're not passing any value and you don't want any value to be returned then you can just use this moon bracket to kind of for the function and this is an instance instant method basically i can do i can call it on on my instance here and that is going to implement that method usually if you want to pass an argument you specify the argument name and then argument type let's say let's say i pass another parameter like raise this particular hand i i say so here i'm passing one parameter to my method and if you want to return a value you need to use this arrow and after arrow you can tell what is going to be a written type so if you want to pass multiple arguments you can just put them by separate them i comma argument one argument type then argument two call an argument type and the written type now something which is really interesting about suite is that you can return multiple values also in the written type so there's something we'll see and here we are just defaulting a parameter just like let me show you what that means let's say here the value of i is your passing is four but we want a default value for that particular parameter the way we can do it is after your parameter name and parameter type you can put something equals to something that is going to be the default value same thing let's say here i'm going to put false so if i'm going to pass four then it is going to print whatever value i'm passing but if i don't pass that value it is going to pick the default value now notice here if i have a default value i do not need to pass that parameter you know it is not mandatory to pass that parameter for example i can just call this and it is still going to work because for both the parameters i have a default value which is denoted by this equal now you have downloaded the app i think the snail move app there's basically a simple app so we shared there are four buttons only one works so far if i click on this it just moves if it's on the left hand side it moves to right if it's on the right hand side it moves to left and i have this method here which doesn't now it doesn't have any parameter that is expecting and i'm just using it when the move button is being tapped i want you to first run this app and see how it works and probably pass these values and arguments to start with and once you are there you can implement these three methods and then you can you can see how to work with methods in Swift so this is the this is the assignment actually you can it you can start with the Swift programming guide to go back to some of the things that i mentioned like you have methods here and you have functions here so these two things are important you can kind of refer to whatever i mentioned by going to the method section here and and functions okay yep try this one now open an iphone 6 simulator otherwise it's going to if you let me explain what is happening so animate with duration is a method on the uivu class like animate with duration and it takes basically one parameter which is the duration for whatever time it is going to run and there is this animations basically closure closure is something causal is going to talk about after this thing but you basically once you open this for duration you can pass a float value whatever you want you can specify as a 2.0 and double click on this one and within this section you can animate whatever you want you can change the frame of any component you want this is a very simple animation so what we are going to what we are doing here in the image view as i mentioned the frame is basically for every view component it has a frame or basically a rectangle within which this view is being drawn it has four parts to it it's like it gets created by this method again cg-rect make it is four parts the first part is the the pixel sorry that the position that x position from left the second part is the y position from top third is the width fourth is the height so here width and height is going to stay same for our animation we are not going to change the width and height unless let's say you want to you know increase the snails width and height as it is moving um we can do that if you want to do but we don't want to do that for this exercise we the width and height is same we are just going to change the position the first is the x value second is the y value and these are the two values we are going to change so first we are checking that the initial value when is the left it is a pixel 20 pixel from the left hand side so we are checking if it's 20 pixel from the left hand side then move it to the right side which is go to 295 why also i'm not moving for the first example which is just the um you know when the move button is tapped so that that's about the animation code so there are a lot of thing you can do one is you can pass the duration for example as a parameter that is one thing you can do second is you can pass the direction as a parameter like left or right you can pass the direction as a parameter and just call those things from from this um accents let me just do one small bit which is the duration which is probably easier but then so i'm going to pass the duration from my method so if i change it to 2 it is going to move little slow it's going to complete the animation in two seconds if i make it one it's going to go a little faster you can pick this value like you can put a slider and change this values also and pick uh pick the duration from the slider also if you want but the idea is to be able to change some of these properties and call it from these accents so that you kind of are you are aware of how to call and how to make use of your custom methods yeah from the top so you can actually see if you go to the storyboard right if you go to the storyboard and click on the snail and go to the size inspector this is where i can see the x value is 20 and the y value is 472 um for the current position and then you can kind of adjust accordingly i have um an enum and i have four different uh basically enum uh types um based on the animation that i want to do i have right left move and the trip um these are the four different types and similarly for whenever the button is tapped i'm just calling the corresponding or passing the respective direction and i have a switch case statement here i'm just checking what is the direction that is being passed obviously the duration is being also passed and for left it is only going to move to left and if it's already there in the left i'm not doing that check so if it's on the right hand side it will move to left if it's already on the left hand side it will not move same with the right hand side but the animation i'm doing it individually for each of the cases for move it is just going to move if it's on the left hand side it is going to move to the right and if it's on the right hand side it will move to the left the thing is for the trip i have another method here now this is where it kind of gets really crazy there is another method on uiview which is uiview animate with durations and there is a completion handler now you have you still pass the duration you still pass the animation block but you get an opportunity to run something else when the animation is completed so what i'm doing is i'm just doing it first i have irrespective of where the snail is i'm going to like when i start and go on trip it is going to start from the left hand position and it is basically chaining the animations so it starts from left then it moves to right then top left bottom so these are the four animations that i'm doing that's why i'm dividing the duration by four so this kind of thing is i think is going to be much easier with closures but anyway this sample code i'll i'll share with you but before that i want to kind of highlight one more thing if you see in here when i'm calling the method it is not asking me to pass the first argument name that is because the first argument name is optional and if you want to if you want to receive the first argument name you can write something like so this is going to be the argument name that is you are going to use when you're calling the method whereas the local reference is this so for example i can call it you know um you know for example dor i can call it i can use that when i call the method wherever whereas my local reference within this method is going to be this name that i'm going to use after that you can do to do the same thing for other methods also for example i can use the same name for the second parameter also just that the the local reference needs to be different whereas when you're calling the method the the name you are going to use to call the method it can be same but however to avoid confusion you need to name them differently so that you know what individual argument means to the method so yeah that's about methods there are bunch of things additional things that i kind of couldn't cover here for example if you don't want to kind of pass i think this is going to work if you want to remove the method name all together we saw like if you want to force user to pass the method name then you write like this you put a if you want the user to pass the argument name you put some argument name and this is going to a local reference for example you want user to not pass the argument name and you start with underscore and then in that way you can remove the need of passing the argument name i think it starts with yeah underscore yeah so i think the name the internal name needs to be different so so this is about method the next section is closures and kazel gave a presentation in one of the ios meetups and he kind of talked really in details about closures and he has some really good examples um i'll just pass to kazel to cover the next section for closures so for you are now aware of function but so by display the previous definition so closure are basically what you call it as a function pointers okay so what exactly it is and how it works like a simple anyway so here if you if you think of a function it has a simple signature like a function is like a function print that's a very simple function which does something printing part okay so this is basically a more fundamental side of the language and not on the ui side okay so you can have parameters in functions like we have a function called act it has a signature a function signature is this okay right now we have seen a function say display it has a signature this okay it does nothing it takes nothing and returns nothing you want to take it something okay display what okay what do you want to display you want to display something which is a string print what okay i'm expanding on it you have you have dealt with function a lot i'm slowly expanding it now display sorry display hello so this will display hello now i want to improve the signature right now the signature of function is it takes an argument of type string what if i give it a number but work because it takes a string so i need to change it to an integer so there's a difference the previous one was having a signature of string and the new one is having a signature of integer okay let's say function double it up what okay it says doubling up what do you want to double up double it up 10 did nothing okay doubling up 10 but it did nothing because the signature doesn't returns anything it should return something so it doubles up and returns an integer integer what like what multiply by 2 i want to return whatever is there multiplied by 2 so doubling up 10 and it is returning 20 so the function signature is it takes an integer and returns an integer okay so in a similar manner we have a another method called add what add does it takes two numbers and returns the sum of it sorry and returns the sum of it here we have given it as add 10 and 20 it returns some from Swift 3 it is compulsory to name the first parameter as well so i'm still using the old x code the new x code says that that this is required okay but before Swift 3 this is optional now considering this signature let's move on you have a type and this is signature sum two numbers takes two numbers return one number say hello takes an integer and returns something hello then the name as you can assign values to a variable like function test you can create a variable let temp equals to what so this what in the right hand side is the argument and you have a created a identifier variable called temp and you assign the value of what to temp the what is of type string why i'm focusing on type because a function signature is also a type here here the type is a function which takes two numbers and returns one number okay so we created an identifier called fn we called it say hello i can name it like Swift is good okay and okay so here i haven't created a function named Swift is good i've simply pointed this function to say hello i have told this function that whenever i'll make a call to Swift is good consider it as say hello okay now making a call to Swift is good and sorry making a call to Swift is good and making a call to say hello is exactly the same but here you're directly making a call to a function whereas Swift is good you're telling Swift in good Swift is good to make a call to a function okay so coming back to the point like what is closure just now you people have done an example on animations what animation does it takes what to animate and there is a completion as well okay so those are closures basically you define a block that what it has to do here i have created a sample function called run okay run don't know that what it has to do you're just telling it but what it has that what values it has there's a description then the arguments and you're telling this run method that what you have to do it has to run a method which has a signature which i just now told for some so any method it doesn't care it will invoke that method with the argument so here is how we are making a call to run some of two values first is 11 second is 12 and method to run is add when you make a call to this run you have passed the argument method to run as add it will method to run will point to add and well when it you will invoke it first and second it will sum it up 11 and 12 and it will print as 23 so later if you have another method called subtract you simply change the name to subtract and it will subtract the two values so basically you are assigning it just like if you have a C background if you know the pointer it's the same thing you're pointing to it okay now coming back to the topic of closure closure is basically a function without a name sometime what you want to do is you don't want to create a method you just want to give that method to someone who can execute it okay you are not going to reuse that method again again but you just want to create a block and give it to someone for example we have an array I hope many of you are aware of array it has some values now you want to sort all these values in some way okay either that is increasing order or a decreasing order how do we compare two values you basically check that which one is bigger okay that check is called as predicate you check it and you either return true or false okay so here there is a predefined function called sort just now as I explained that in the previous demo in the previous demo that this run takes an argument method to run same way sort is a method added by apple in the array class okay you give it something and it will it will sort something in increasing or decreasing order whatever you want so there is sort method from the swift library if you see closely this is the signature first element second element and the boolean value okay so this sort takes in a function which has two elements and a return value of type boolean here we created since all there is something called it to infer the data type all these are numbers all the numbers are inferred as type integer if you write names over there it will be inferred as type string feeling sleepy all right okay so so in this argument this element both these elements are inferred as integer okay as you have seen that this sort method yeah it takes two elements and return a boolean value so it takes a closure basically so we created we created an increasing order function for example the first one a decreasing order they have a same signature it doesn't matter what name you give but the signature I should behave exactly how it is expected inside is your logic number one is smaller and number two is bigger if it is true then sort it that way okay now score dot sort increasing order you can see that it is all there increasing order and this is decreasing order so rest of the task is carried out by the array that what it has to do okay you just need to tell that which one is bigger or which one is smaller I'm not just talking from the point of view where you have integers but sometime you have got different objects as well like you want to sort images whichever image has got more red in it you want to sort it that way so how the array will know about it you tell that array here you take out the red component from the image you compare it whichever has more red component in the image like images red green and blue combination of these three you sort it by red sort it by green sort it by blue so the image which is more reddish it will appear the last if you increase and decreasing order the image which is more reddish it will come at the first so you can do those things based on your requirement now this signature is a bit like you cannot create this predicate everywhere okay so what you can do you can make it small small how like you can put the body right there here so we have told the sort image sorry sort function that this is the signature what you expect okay in is something which is necessary here because you haven't given it a name if there's no name then along with the signature along with the signature you suffix it with in after in whatever is there that's a body so here the return statement okay and this must be in a block this block is called as closure there's no name but you put in the functionality right there and this is what you did in the completion handler if you remember in animations you can make it shorter because you know that the data type of sort is inferred so this integer is not required so the integer integer type is not required so what you can do is like you can simply remove the data types and return this statement that's very short okay now the rest of the sort is an increasing order if you go ahead then you can write all the same all the things in the same line in one line you don't need to write into two lines okay it's all in one now next another form you know that in the same line if you're writing it then this return keyword is also optional okay so you don't need to write in return since it is a single line statement you can simply mention the two arguments n is compulsory here I can simply do the comparison and return even shorter this is argument at index value 0 this is argument at index value 1 okay so you tell in the block the shorthand notation that whichever is at index value 0 you compare it with index 1 just sort it and give it back to me more shorter since they are just two arguments okay since they are just two arguments that's a power of swift language okay since they are just two arguments one is on the left hand side because this is a comparison operator a comparison operator cannot exist without two things okay one is left hand side and one on the right hand side okay so just tell the comparison operator that whichever is on the left hand side compares it to the right hand side and return me a value if this condition is true so you saw that the sort was quite big and it was replaced by just one character and since it is just one character the these curly brackets are also optional so you don't need it okay there's something called trailing closure if you're not very comfortable with with this function and you want to treat function like a function what you can do if and only if and only if it's a last argument okay what you can do you can take out this condition you can take out this condition from here it is a last argument not the only argument okay it should be the last argument and simply put it behind like this so that's what is done here okay now since this is the last argument you can put it like this but if it is the only argument you can put it like this as well okay this is mostly like what you did in completion handle just put the brackets and if you go back and see your logic you'll find that in this place you have put your logic okay you can write anything you can print a name and you can write just anything yeah that's all auto closure I can tell but it's something we'll take it later so simple closure is something within these curly braces or moustache brushes and the logic can say now the concept of last argument which I just now explained show you here like this method to run is the last argument okay now this subtract I have used the previous one sorry let's see another variant of this run method okay so I want to multiply method to run is print 10 multiply by 20 sorry yeah so 11 into 12 is 132 I can make it simple you don't you can simply put the bracket here and since this is the last argument remove the name yeah then you can simply the last the last argument can execute like this you don't need to give it a name so you can see the difference that method to run is subtract and if it is the last argument so let's make some signature change okay I make another one here add a dummy something okay so you'll find here an error because this is not the last argument there's something expected after this as well which cannot be written here so if you have such a situation what you can do is like you can simply give it a name like method to run the last argument is dummy is true whatever it is close it so to run so if this is the last one then you don't need to give it a name and that is very much simplified like so this is actually what was happening when you were running animations so there are many other language concepts which are very much required in Swift and you must know if you know you can write better code thanks you can yeah okay you can try you can try out the same same code which one this one yeah if I was like we did the animation where you have written the completion the the function which actually animates the entire thing it doesn't know that what what you mean you tell it in the closure block that what you want right it does the thing but you must tell that what it has to do yeah so normally what happens if you really want to give it an argument as a number number variable like 10 20 30 then that is very hard coded like that doesn't give you flexibility here the flexibility is animate the the animation code animates but what has to animate what values it has to be that this decision is up to the level so in the closure block you can give such a such logic over there in the next lesson is this thing called nsur session which is for making network calls and there is this library called almofire which you can use actually you should use almofire other than yeah that's that's Michael Zhang yeah this is a really good library for making network calls but you still need to understand the fundamentals behind it and that is why we'll touch upon nsur session and there's another thing called nsur connection but you know some of you are asking what are the other kind of guides you can follow to learn right first of all go back and kind of watch these videos if you have time but if not I hope you watch that one hour video of that you know WWDC that I said with you but let's let's say so this is this is a really good book app programming guide for iOS it tells a lot of things about the internals of iOS so it's like again reading a book normally if you're not building something can get a little boring but these are the fundamentals that you kind of need to learn if you want to build a really good quality app so I will send the links to all all the books so app programming guide is one that I would really recommend for you know for reference and then human interface guidelines is something on the UI side that that doesn't really require you to build anything but it makes you familiar with a lot of view components and I know if you're going into product or if you have plans to go into like UX or in a product side of things you need to read human interface guidelines this is like it tells you what are the different view components out there and what is the best practices of using this view component for example if you see like in the first lesson we did the sg port app using buttons now somebody can really build an app using buttons but that you shouldn't right and then what are the components you need to use and when to use most importantly whether there's so many different components available when to use which component and this human interface guideline will give a really an overview and most importantly here there's this section UI elements like this is also really kind of a big guide but if you kind of go through the UI elements part itself that that itself has a lot of insights that you can find out from this guide and then raveindelige.com it is basically a really good tutorial site they they have a lot of video tutorials and they have they have video tutorials for Swift they have written tutorials for Swift and they have some books here also which basically teaches you how to do programming by doing simple simple applications I used to write at some point of time for Ray and if any of you are planning to buy a book I can probably try to get some discounts for you I don't know maybe he usually gives 10% discount or something this book is $50 let me see the one that I'm talking about anyway just wait for few more months and you can probably for now refer to the existing tutorials because Swift 3 is coming and then going to rewrite the book but the one I was talking about is this there's like beginning programming with Swift 2 and they have pdf version which is like 55 USD but yeah that's about it and then join the study group we are going to have regular sessions in the study group maybe we'll have one more or two more sessions in the study group about the lessons itself that I'll conduct but after that it will be I would encourage participants to come up with their own questions and we can solve the questions or answer the questions in the study group but there is an iOS meet-up also that is happening next week you can just come which is here at PayPal but not on 9th floor this is happening on 7th floor again these talks are usually for intermediate and advanced developers but you can kind of come along and see what other people are talking about and then at least get to know other developers that you can ask questions to so yeah so this is happening on Thursday 6 30 p.m on 7th floor and we have the iOS Dev Scout Facebook Facebook group which you can join and we have like 3000 over people there but I kind of want to wrap this session by thanking all the people who helped me and usually it is hard to conduct a session and thanks to all the volunteers who helped me in this lesson and in the previous lesson and and thanks to Michael and that's why I kind of opened up for recording the recording the videos Michael has been doing it for all the meet-up groups it's a crazy amount of work they're like I don't know 30 40 meet-ups happening in Singapore he and his volunteers Bina is one of the volunteers that Michael has and then where they got all the sessions and engineers.sd is where you can literally find videos of all meet-ups in Singapore you can go to these organizations like let's say if you're interested only in iOS talks then just go to iOS Dev Scout and and you can you can see all the all the talks that we had really a lot of talks and here's here's recorded and then we have some some talks from the conference that also Michael helped us to record last year iOS.com sd there's some good talks here as well it is happening this year I still need to update the website but iOS.com sd is what you should check it is happening on 20th and 21st of October and hopefully by October it should be proficient enough to kind of understand all the talks so but irrespective of that we'll have some discount for iOS Dev Scout members and for the SWIP study group members but with that I would thank all of you as well because you spend your Saturdays coming here and learning something thank you all and I will say the sample quotes and the slides I know I didn't manage to send for last class but I'll keep bugging you guys with more materials and resources until you tell me a soup you're just sending too much email stop now but yeah hope to see you in the SWIP study group feel free to hang around if you still need to need help with your sample examples or you know the code we'll be here until five and then that is when you kind of we'll wrap up but yeah that's the end of this lesson thank you