1 00:00:00,700 --> 00:00:01,830 Welcome back again. 2 00:00:01,840 --> 00:00:07,700 In this listen I'm going to show you how to use a mass their detail template application. 3 00:00:07,870 --> 00:00:13,380 And that's the one that you find when you start a new application in X quote and there isn't a lifted 4 00:00:13,420 --> 00:00:19,390 intentionally for now is I want others to have a better understanding of how table views work and how 5 00:00:19,390 --> 00:00:21,940 the different methods they come together. 6 00:00:21,940 --> 00:00:28,150 I personally am not a big fan of using templates anyway because I kind of don't understand how they 7 00:00:28,150 --> 00:00:29,260 are doing things. 8 00:00:29,260 --> 00:00:35,230 And I would rather if I know exactly how I put an application together but in case you ever wanted to 9 00:00:35,230 --> 00:00:39,250 do a quick and dirty version of a table view you could essentially use that. 10 00:00:39,250 --> 00:00:45,700 So I'm going to go into export and yet I'm going to start a new application called a master detail application 11 00:00:45,700 --> 00:00:53,620 type and I'm going to call it master detail app and what it essentially does is it makes a table view 12 00:00:53,650 --> 00:00:58,310 with a detailed view controller as well as a split view controller. 13 00:00:58,360 --> 00:01:04,480 So it is a split view controller such as this one that the Smith view controller has two pieces of view 14 00:01:04,480 --> 00:01:11,080 controller one of them being a navigation controller with a table view the other one being in navigation 15 00:01:11,080 --> 00:01:13,930 controller with a detailed view controller. 16 00:01:14,170 --> 00:01:19,900 So every time you tap on any item in the master it shows you the details of that in the other view. 17 00:01:20,230 --> 00:01:25,870 Let me run the application first and then I'm going to try to explain to you how this thing is put together 18 00:01:26,200 --> 00:01:27,460 and you can take it from there. 19 00:01:28,240 --> 00:01:33,670 So once the application notes you have a table view you have an add by then and you have an edit by 20 00:01:33,670 --> 00:01:34,020 then. 21 00:01:34,210 --> 00:01:39,610 And if you rotate your view you will essentially have only the table view and the master viewpoint aura 22 00:01:39,670 --> 00:01:42,120 is essentially collapsed or hidden. 23 00:01:42,220 --> 00:01:47,980 If you type on the master that appears in here and you can again see your table view in the table view 24 00:01:47,980 --> 00:01:54,490 everything you top on the plus within it does nothing but adding the current time as one of the setters 25 00:01:54,550 --> 00:02:00,100 and into your array as you add them it constant the outdoors and every time the top on any of doors 26 00:02:00,130 --> 00:02:06,940 is essentially going to take you to the detail the you controller of those details if I go back to master 27 00:02:07,200 --> 00:02:13,440 click in here becoming there and we see that obviously this is happening through our navigation controller 28 00:02:13,840 --> 00:02:20,200 and the detail is being passed through a Segway and we're calling a Segway every time with top on one 29 00:02:20,200 --> 00:02:28,440 of the items from our cells of our table view now it's going here in the master view controller you 30 00:02:28,450 --> 00:02:33,310 really don't have anything that is all that different than what we have done in the past in the view 31 00:02:33,310 --> 00:02:40,420 did not you have to buy dance the left bar by then item as well as the right bar but an item as a go 32 00:02:40,420 --> 00:02:46,590 through this I'm going to format the court so it becomes more familiar both for myself and for you. 33 00:02:46,690 --> 00:02:53,050 So that's the left bar but an item then after that we have the right what about an item and then depending 34 00:02:53,050 --> 00:02:58,840 on the orientation of the device we decide whether we have a split and if we have a split which one 35 00:02:58,840 --> 00:03:05,770 should be the detail view controller I will come back to this in a bit within a half things such as 36 00:03:05,830 --> 00:03:12,460 inserting a new object which essentially in sets a new data into the objects objects is the array that 37 00:03:12,460 --> 00:03:13,880 we are using for everything. 38 00:03:13,990 --> 00:03:16,500 This is what we usually called Cities are a. 39 00:03:16,510 --> 00:03:23,170 In all the tests we did so far and then we make a new index spot and we add that as an element of the 40 00:03:23,530 --> 00:03:31,210 off the table view we usually did this in a slightly differently we added that to our array and we reloaded 41 00:03:31,210 --> 00:03:38,110 our table view by inserting a row into a table view you end up having a little bit of an animation which 42 00:03:38,110 --> 00:03:43,420 is something that is nice and you end up you know you end up seeing a bit of an animation here that's 43 00:03:43,420 --> 00:03:48,730 when we press in here we see that little animation if you were just to reload the table view they would 44 00:03:48,730 --> 00:03:50,530 all just appear together. 45 00:03:50,530 --> 00:03:52,930 So that's the one good takeaway from this. 46 00:03:52,990 --> 00:03:59,920 The next thing is preparing for a Segway which if the Segway is the sure detail we find then they expand 47 00:03:59,980 --> 00:04:06,310 on the most important part of it is this one we send an item to the other side which is the detailed 48 00:04:06,340 --> 00:04:14,530 view controller in terms of the data source for a table view we have one section we have as many objects 49 00:04:14,530 --> 00:04:21,640 in our array and for the cell for right index card we have a cell with an identifier called cell and 50 00:04:21,640 --> 00:04:28,300 we get the object that we want to show as a date and we put it there in our text label we didn't have 51 00:04:28,350 --> 00:04:34,840 I can edit role which is the one that allows us to delete or remove stuff and in the comments editing 52 00:04:34,840 --> 00:04:40,810 a slide which is something we did I think in just the listener go the video editing is night if it is 53 00:04:40,810 --> 00:04:47,170 delete then we remove the objects from the array we delete the rules just like what we had done before 54 00:04:47,400 --> 00:04:53,730 and we are not really doing anything in the insert just yet so that's essentially how our master view 55 00:04:53,740 --> 00:05:00,660 countries put together in the detail view controller things are actually even easier we have one table 56 00:05:00,810 --> 00:05:07,260 that shows us the value that we have on the detail item in that item is the one that gets passed on 57 00:05:07,290 --> 00:05:11,580 between the master view controller and the detail view controller. 58 00:05:11,580 --> 00:05:18,300 So when the view lords essentially we say configure view fish configuration essentially runs that finds 59 00:05:18,300 --> 00:05:24,150 the detail item and from the detail item essentially populates the value on the label. 60 00:05:24,180 --> 00:05:28,390 The only thing that might be new for you guys is here in the app delegate. 61 00:05:28,410 --> 00:05:33,450 If you go in here and gets rid of everything we don't need in the app delegate did finish launching 62 00:05:33,480 --> 00:05:35,430 application with options. 63 00:05:35,430 --> 00:05:41,030 We find that a split view controller and we delegate from it to here. 64 00:05:41,100 --> 00:05:46,970 By doing that we get access to this one function let me delete everything else because we don't really 65 00:05:46,980 --> 00:05:47,640 need them. 66 00:05:49,380 --> 00:05:52,050 So the only function that really matters is this one. 67 00:05:52,080 --> 00:05:55,080 Let me read for my dad 1 properly as well. 68 00:05:55,110 --> 00:05:57,630 So we have a better understanding of what's going on. 69 00:05:58,080 --> 00:06:00,940 This one is called collapse secondary. 70 00:06:01,020 --> 00:06:07,110 So the reason we have that is if you want to be able to collapse the second of view controller in a 71 00:06:07,110 --> 00:06:08,560 situation like this. 72 00:06:08,580 --> 00:06:15,090 This is a split view controller right now but one part of their split view controller is actually hidden 73 00:06:15,150 --> 00:06:16,360 or is collapsed. 74 00:06:16,410 --> 00:06:22,470 Then we top on the mask that it actually appears in here and that's the purpose of collapsing a cyclone 75 00:06:22,470 --> 00:06:25,400 3 part of a split view controller. 76 00:06:25,410 --> 00:06:29,600 I actually encourage you to spend some time on this application. 77 00:06:29,640 --> 00:06:35,760 Like I said I personally have never used this application for any real life situation simply because 78 00:06:36,030 --> 00:06:41,440 I want to know where things are and I want to know why I have called something in a certain way. 79 00:06:41,490 --> 00:06:44,700 Obviously calling something objects doesn't really cut it for you. 80 00:06:44,700 --> 00:06:50,520 You need to call it based on the objects that you have and then based on that array you might want to 81 00:06:50,520 --> 00:06:51,330 do things. 82 00:06:51,330 --> 00:06:54,910 Same thing applies to pretty much everything in this application. 83 00:06:55,080 --> 00:07:01,530 But in saying that because it's such a good design and everything functions well in it I actually suggest 84 00:07:01,530 --> 00:07:07,050 that you spend a little time going through every little bit of it perhaps breaking all of these connections 85 00:07:07,080 --> 00:07:13,470 or deleting all of these in the storyboard remaking them on your own and rewriting the code for every 86 00:07:13,470 --> 00:07:14,070 part of it. 87 00:07:14,070 --> 00:07:18,300 So you have a very good understanding of everything that's happening in here. 88 00:07:18,300 --> 00:07:24,260 This is kind of our last lesson when it comes to table views on table view controllers. 89 00:07:24,330 --> 00:07:29,620 By now you should be able to do most everything that is doable within a table view. 90 00:07:29,790 --> 00:07:31,280 So with that in mind. 91 00:07:31,550 --> 00:07:36,410 Let's keep it up to here and I'll move on to our next lesson which I think is an exercise. 92 00:07:36,510 --> 00:07:42,540 And like I said I encourage you to spend some time on this application and get a sense of how they put 93 00:07:42,540 --> 00:07:43,510 things together. 94 00:07:43,530 --> 00:07:47,200 Any part of it that is unfamiliar to you or you don't know what happens. 95 00:07:47,220 --> 00:07:49,300 Try to google it or drop me an email. 96 00:07:49,320 --> 00:07:52,620 I will get back to you wait you know what is happening in that place.