1 00:00:00,540 --> 00:00:01,690 Welcome back again. 2 00:00:01,710 --> 00:00:06,600 In this lesson I've been talking to you about this split view controller and a split view controller 3 00:00:06,630 --> 00:00:13,200 is some sort of a controller that breaks your screen into two separate parts where each part is controlled 4 00:00:13,200 --> 00:00:15,540 by a different view controller. 5 00:00:15,540 --> 00:00:22,800 It is originally designed to be a controller for having a table views within larger screens. 6 00:00:22,800 --> 00:00:29,280 That's the screen that you see when you open your e-mail application on a path that you have a table 7 00:00:29,280 --> 00:00:34,450 viewpoint or on the left side and then the body of your e-mail on the right side of the screen. 8 00:00:34,470 --> 00:00:40,110 You could do that even an iPhone when you rotate your iPhone and you keep it in the landscape more than 9 00:00:40,110 --> 00:00:42,120 you got your e-mail application. 10 00:00:42,120 --> 00:00:47,580 You would have a lot of table view settings on the left side of the application and the right side shows 11 00:00:47,580 --> 00:00:50,010 you the actual threat of different emails. 12 00:00:50,340 --> 00:00:54,990 So first I'm going to give you a quick demonstration of how it could work for an application such as 13 00:00:54,990 --> 00:01:01,200 e-mail and then I'm going to show you are the details of it how it is actually put together. 14 00:01:01,230 --> 00:01:06,070 So I'm going to go to X code and it will then start a new application. 15 00:01:06,180 --> 00:01:09,410 And this part you don't need to do because it's just a demonstration. 16 00:01:09,420 --> 00:01:15,660 I'm not going to explain how it works because we have a whole section dedicated to table view controllers 17 00:01:15,660 --> 00:01:21,390 and collection view controllers but for now in the new application I'm going to choose master detail 18 00:01:21,720 --> 00:01:24,040 as opposed to what we usually do. 19 00:01:24,090 --> 00:01:27,050 I'm going to say this application is actually called temp. 20 00:01:27,180 --> 00:01:32,660 That's a naming convention I have for whenever I know and when I delete something really really soon. 21 00:01:32,810 --> 00:01:37,770 And if you're on this application will end up having a table view controller which is something that 22 00:01:37,770 --> 00:01:42,810 would be the study in the future but you will also have a split view controller. 23 00:01:42,840 --> 00:01:45,390 Let's see how the two of them they work. 24 00:01:45,390 --> 00:01:47,550 So if I rotate this simulator. 25 00:01:47,550 --> 00:01:55,010 Now that is by pressing command on arrow buttons or going to hardware rotate left or rotate right. 26 00:01:55,080 --> 00:01:59,200 If I do that we would see that we have this a screen that I press on the master. 27 00:01:59,250 --> 00:02:04,710 Another viewpoint or appears and I can press on that little button maybe I can make this a little bit 28 00:02:04,710 --> 00:02:06,130 larger as well. 29 00:02:06,420 --> 00:02:09,500 And I will have these table view cells in here. 30 00:02:09,510 --> 00:02:11,100 Each of these is called a cell. 31 00:02:11,100 --> 00:02:18,630 I mean I type on them that content appears on a different view controller which is the essence of having 32 00:02:18,690 --> 00:02:25,560 a split view controller a screen is a split between this view controller the one that we call mass there 33 00:02:25,680 --> 00:02:28,260 and the other one which is called detail. 34 00:02:28,260 --> 00:02:35,400 Now if you're using a smaller device such as a phone the master essentially slides over the detail. 35 00:02:35,660 --> 00:02:40,920 And if you're working with a larger device such as an eye apart then the master viewpoint area will 36 00:02:40,920 --> 00:02:43,800 be permanently there on the left side of the screen. 37 00:02:44,250 --> 00:02:46,480 So that's the design of it. 38 00:02:46,470 --> 00:02:50,550 Now let's go ahead and see how they do this thing and what you could use it for. 39 00:02:50,610 --> 00:02:56,970 Like I said it's primarily used for this purpose for having a table view and it's kind of a built in 40 00:02:56,970 --> 00:03:00,660 feature there but it kind of helps if we know how they built it. 41 00:03:00,660 --> 00:03:04,080 So if we need it we could make adjustments sweet. 42 00:03:04,290 --> 00:03:10,310 So I'm going to go back to school and I'm going to stop this application is thought a new one I'm going 43 00:03:10,310 --> 00:03:16,500 to call this one to be a singer of your application I'm going to call it my split vote just a split 44 00:03:17,550 --> 00:03:19,870 view controller app. 45 00:03:20,850 --> 00:03:23,510 So that's my Smith your controller app. 46 00:03:24,000 --> 00:03:29,010 And the moment it load I'm going to head into my storyboard and design this split view controller. 47 00:03:29,040 --> 00:03:32,210 So the first thing I'm going to do is and delete this view controller. 48 00:03:32,310 --> 00:03:38,120 I'm going to say I have a split view controller which is somewhere up here. 49 00:03:38,160 --> 00:03:44,090 This one at the moment you did I guess with your control is going to bring a lot of his stuff with it. 50 00:03:44,100 --> 00:03:49,590 I'm actually going to delete everything except for this one which is the master of this split. 51 00:03:49,590 --> 00:03:52,650 You're going to read that shows the master of your controller. 52 00:03:52,650 --> 00:03:58,610 So I'm going to delete the route view controller the navigation controller and this other view controller. 53 00:03:58,620 --> 00:04:03,920 So we are left with this one which is of the type split view controller. 54 00:04:03,930 --> 00:04:06,290 Now I want to build everything on my own. 55 00:04:06,290 --> 00:04:09,930 I want to see how these two different things are actually connecting to each other. 56 00:04:09,930 --> 00:04:15,930 So I know for a fact that the split controllers they require at least two view controllers and master 57 00:04:15,920 --> 00:04:18,760 view controller and a detailed view controller. 58 00:04:18,780 --> 00:04:20,530 So let's go ahead and add those two. 59 00:04:20,550 --> 00:04:23,080 I'm going to say I have one view controller. 60 00:04:23,280 --> 00:04:28,980 Let's make this one be perhaps a brown color. 61 00:04:29,010 --> 00:04:34,950 So I'm going to say this is my master view controller and then I'll have another view controller. 62 00:04:35,070 --> 00:04:36,720 I'm going to put it in here. 63 00:04:36,720 --> 00:04:43,040 Let's say this one is maybe it's like this color maybe it is pink. 64 00:04:43,050 --> 00:04:45,960 So that's going to be my details a view controller. 65 00:04:45,960 --> 00:04:51,450 And now I'm going to go ahead and select this view controller hold controller and I go over here and 66 00:04:51,450 --> 00:04:56,290 say the relationship is mass their view controller for the brown one. 67 00:04:56,590 --> 00:05:02,430 And then when I repeat the same process for the pink except that this time I'm going to say the relationship 68 00:05:02,490 --> 00:05:04,440 is detailed view controller. 69 00:05:04,950 --> 00:05:10,440 So now each of them is one of their view controllers of this split view controller. 70 00:05:10,800 --> 00:05:15,640 And since I don't have an entry point to this story of what I'm going to select this great view controller 71 00:05:15,660 --> 00:05:18,150 say it is the initial view controller. 72 00:05:18,810 --> 00:05:20,780 So by now we have this setup. 73 00:05:20,910 --> 00:05:27,420 And surprisingly my pink view contrary is showing me a navigation bar and that is because the design 74 00:05:27,420 --> 00:05:32,530 of a split view controller expects this view controller to be a navigation controller. 75 00:05:32,580 --> 00:05:37,370 So it's best if the embed the pink one within a navigation controller. 76 00:05:37,670 --> 00:05:44,520 So I'm going to select the pink one that is my details of your controller and say Ed embed in a navigation 77 00:05:44,520 --> 00:05:45,180 controller. 78 00:05:45,900 --> 00:05:53,080 And that's just like the bare basics of having a split view controller that has one master view controller. 79 00:05:53,100 --> 00:05:56,040 One detail view controller. 80 00:05:56,040 --> 00:06:01,200 Now I will run the application up until this point just so that we can see what we get so far 81 00:06:05,820 --> 00:06:10,450 so now that my app is low that I can see that on the left side I'm seeing the brown view controller. 82 00:06:10,460 --> 00:06:12,510 That was the master of one on the right side. 83 00:06:12,510 --> 00:06:18,210 I see the pink one there is obviously only visible when my application is in the landscape mode. 84 00:06:18,300 --> 00:06:24,060 If I rotate back I will only see the master view controller and that's a very good design because in 85 00:06:24,060 --> 00:06:27,950 a poor state and with it kind of doesn't make sense to see a split in the screen. 86 00:06:27,960 --> 00:06:33,090 There isn't enough space for doing this bit of a vertical split essentially. 87 00:06:33,540 --> 00:06:37,740 So let's go ahead to code and see what else we could change in here. 88 00:06:37,740 --> 00:06:43,020 Something that is quite important and you might have noticed is because each of these scans are taking 89 00:06:43,110 --> 00:06:49,070 apart of the size of this quarter the screen it makes sense that we set alter layout and constrains 90 00:06:49,260 --> 00:06:51,270 for anything that be making it. 91 00:06:51,540 --> 00:06:52,800 So I'm going to keep that in mind. 92 00:06:53,460 --> 00:06:59,130 So the first thing I want to do is I want to be able to have something in my master view controller 93 00:06:59,160 --> 00:07:03,120 that controls something in my detail view controller. 94 00:07:03,210 --> 00:07:09,090 So let's say you have a button here in the brown that controls the text somewhere on the on the pink 95 00:07:09,390 --> 00:07:12,600 and if you manage that then we can manage anything similar as well. 96 00:07:13,000 --> 00:07:14,730 So we're going here to the brown one. 97 00:07:14,880 --> 00:07:16,530 Say I have a button. 98 00:07:17,400 --> 00:07:23,290 So let's find that by then when I place it here. 99 00:07:23,690 --> 00:07:26,160 Say it is like that. 100 00:07:26,450 --> 00:07:35,330 It also has a pink bygone color so it kind of says what it does and says change it to something and 101 00:07:35,330 --> 00:07:37,840 then I'm going to set the constraints for it. 102 00:07:37,940 --> 00:07:46,470 A space leading the space trading the space on a height and height. 103 00:07:46,730 --> 00:07:51,170 I'm also gonna go ahead into the pink view contour and add a label. 104 00:07:51,260 --> 00:07:56,470 So in here I'm going to say I have a label I'm going to place it in here. 105 00:07:56,780 --> 00:08:03,130 Say my label is something like that it has a different bygone color. 106 00:08:03,160 --> 00:08:03,930 Maybe you're right. 107 00:08:03,940 --> 00:08:05,900 So we can't see what's going on. 108 00:08:06,040 --> 00:08:07,530 A bit of a larger text. 109 00:08:07,540 --> 00:08:16,420 It has the same height always it has a trailing and a leading space because it tries to intrinsically 110 00:08:16,420 --> 00:08:20,390 find the size of it or infer the size of it from the text. 111 00:08:20,410 --> 00:08:26,350 It kind of shrinks it so you have to go to the auto layout and manually change this number to whatever 112 00:08:26,410 --> 00:08:28,850 you want which is 16 in this case. 113 00:08:29,050 --> 00:08:31,900 And I'm going to say it has a tougher space for a safe area. 114 00:08:32,320 --> 00:08:33,770 So now we have the label as. 115 00:08:33,880 --> 00:08:37,840 The next thing we need to do is we need to have two viewpoint or classes. 116 00:08:37,900 --> 00:08:43,320 I already have one which is the view controller I'm going to delete that so I don't need that one but 117 00:08:43,320 --> 00:08:45,580 I do need is two new ones. 118 00:08:45,580 --> 00:08:52,870 One of them is going to be command and talk with each class is going to be a you eye view controller. 119 00:08:52,960 --> 00:08:55,060 It's going to be pink your controller 120 00:08:58,010 --> 00:09:01,280 and then I'm going to add another one corporate touch glass. 121 00:09:01,400 --> 00:09:07,600 I'm going to call it brown view controller of the type you have your controller. 122 00:09:07,700 --> 00:09:09,730 So now I have two view controllers. 123 00:09:09,740 --> 00:09:14,160 Each of them for one of their view controller outlets in my storyboard. 124 00:09:14,180 --> 00:09:20,890 And when I go for pink one say the class for it is actually pink view controller. 125 00:09:20,990 --> 00:09:22,680 I'm going to select the brown one. 126 00:09:22,820 --> 00:09:28,850 Say the class for it is obviously the brown view controller and then I'm going to go to a split screen 127 00:09:28,850 --> 00:09:31,010 to add some items in here. 128 00:09:31,040 --> 00:09:36,970 So in the split screen I'm going to say for the brown one I need to have an action for the change it. 129 00:09:37,010 --> 00:09:45,880 So I'm going to come in here and say change it has a function or an action called let's say. 130 00:09:45,880 --> 00:09:54,170 CHANGE THE TEXT function at that one then I'm going to go with the pink one and say the pink for your 131 00:09:54,170 --> 00:09:55,190 controller. 132 00:09:55,190 --> 00:10:02,300 And obviously the corresponding pink view controller class I'm going to have an outlet for it that says 133 00:10:03,140 --> 00:10:05,740 my label for instance. 134 00:10:05,750 --> 00:10:08,900 So far we haven't done anything that is completely new. 135 00:10:08,900 --> 00:10:11,190 We haven't done all of these things in the past. 136 00:10:11,300 --> 00:10:17,530 And then the next thing that is important is how are we going to make a change here on this label. 137 00:10:17,550 --> 00:10:23,180 Then that button is clicked and what comes to mind is obviously using a delegate pattern. 138 00:10:23,180 --> 00:10:30,080 Having a delegation that when this is tapped that one uses the delegation information to change itself. 139 00:10:30,080 --> 00:10:35,570 There is either a little bit of a problem with that and that is so far whenever the use of delegation 140 00:10:35,570 --> 00:10:36,130 pattern. 141 00:10:36,140 --> 00:10:39,590 We had a Segway between the two view controllers. 142 00:10:39,680 --> 00:10:42,750 We had a weight that in a prepare for Segway. 143 00:10:42,810 --> 00:10:49,580 We could for instance say the peak of your controller that delegate is equivalent to self of the brown 144 00:10:49,580 --> 00:10:53,700 one but we don't have that in here even though we could write the code for it. 145 00:10:53,750 --> 00:10:59,510 We don't have a Segway directly between these two and even if we had that since we never execute the 146 00:10:59,540 --> 00:11:04,090 Segway we will eventually never have it actually happening. 147 00:11:04,220 --> 00:11:08,510 Today I want to say that let me actually show you the power of the court and how we are going to use 148 00:11:08,510 --> 00:11:11,430 it and then see what problems we run into. 149 00:11:11,840 --> 00:11:13,820 Let us set a new fight. 150 00:11:13,820 --> 00:11:17,810 I want to say a new Swift file and this is going to be called my protocol. 151 00:11:17,810 --> 00:11:20,880 So that's my protocol. 152 00:11:20,900 --> 00:11:26,060 You could essentially call it anything that the insider feed the content of it are what matters. 153 00:11:26,060 --> 00:11:33,880 So here I am going to say I have a protocol on this protocol I'm when I call it are changing text in 154 00:11:33,890 --> 00:11:39,810 pink delegates and this one has only one function. 155 00:11:39,830 --> 00:11:41,460 And that's what function is. 156 00:11:41,710 --> 00:11:44,520 Change that text to. 157 00:11:44,990 --> 00:11:50,660 And I'm going to have to receive an input text which is of course a type a string. 158 00:11:50,660 --> 00:11:54,350 And since we're in a protocol we don't need any body of the function of course. 159 00:11:54,800 --> 00:11:56,690 So this is the protocol I want to use. 160 00:11:56,690 --> 00:12:02,030 So the way I want to use it is I want to have this as a variable for my pink view controller and then 161 00:12:02,030 --> 00:12:05,360 I want to be able to use it somebody in my brown view controller. 162 00:12:05,690 --> 00:12:11,210 So let's go ahead and do just that and let it go to my pink view controller and say up here I have a 163 00:12:11,220 --> 00:12:19,370 variable and what I call it delegate as usual which is of the type change text in pink delegate. 164 00:12:19,370 --> 00:12:26,750 So this is a delegate for my pink view controller which whoever calls it they can change the text. 165 00:12:26,750 --> 00:12:30,910 Now I'm going to clean everything else so they know I don't need I'm going to get rid of all of these. 166 00:12:30,920 --> 00:12:32,860 I actually don't need to viewed it Lord. 167 00:12:32,990 --> 00:12:39,530 So the only thing I need are these two outlets essentially one is the delegate and one is the labor. 168 00:12:39,530 --> 00:12:45,950 Now let's go to a brown view controller and if you recall we always had a situation like this when the 169 00:12:45,950 --> 00:12:53,090 change text was happening when this action is happening somehow or pink view controller dot delegate 170 00:12:53,390 --> 00:12:57,820 should have called its method which I don't remember what it was called. 171 00:12:57,860 --> 00:13:04,640 The problem is we currently can't do that simply because there is no relationship between the brown 172 00:13:04,640 --> 00:13:05,680 one and a pink one. 173 00:13:05,690 --> 00:13:07,210 There is no way between them. 174 00:13:07,550 --> 00:13:12,800 So in in practice there is no way for us to get access to this guy. 175 00:13:12,830 --> 00:13:18,020 We can have a pink view controller which is this ring view controller. 176 00:13:18,020 --> 00:13:21,110 The destination of a storyboard. 177 00:13:21,110 --> 00:13:23,240 So I could in theory do this. 178 00:13:23,240 --> 00:13:31,600 I could go ahead and say let my ping V.C. become a pink view controller and then maybe in my view did 179 00:13:31,610 --> 00:13:37,550 Lord I could go on initialize it but that will have nothing to do with the pink view controller that 180 00:13:37,550 --> 00:13:42,190 is being displayed on the other side of the split view controller. 181 00:13:42,200 --> 00:13:44,980 So that is the problem that they're facing right now. 182 00:13:44,990 --> 00:13:51,060 And to solve that I'm going to say let's do this entire thing with the delegation within another view 183 00:13:51,110 --> 00:13:56,720 controller that controls both of these and has a relationship with both of them. 184 00:13:56,930 --> 00:14:00,200 And that is a you eye a split view controller. 185 00:14:00,230 --> 00:14:03,100 So I go back to my brown and clean of. 186 00:14:03,110 --> 00:14:04,620 I don't need that. 187 00:14:04,790 --> 00:14:12,310 I'm going to start a new file a corporate touch class and this is going to be of the type you eye a 188 00:14:12,350 --> 00:14:14,390 split view controller. 189 00:14:14,390 --> 00:14:17,940 I'm going to call this one my split view controller. 190 00:14:17,990 --> 00:14:22,220 Now this newly created a split view controller it doesn't really do anything for us. 191 00:14:22,220 --> 00:14:24,380 The only thing it does it introduces. 192 00:14:24,440 --> 00:14:26,660 Which one is the brown view controller. 193 00:14:26,660 --> 00:14:28,580 Which one is the pink view controller. 194 00:14:28,910 --> 00:14:32,790 So I'm going to go to a storyboard and say this find this outlet. 195 00:14:32,840 --> 00:14:37,010 It actually has a class which is why a split view controller. 196 00:14:37,040 --> 00:14:42,000 So it now knows all of the connections that are happening here in the interface builder. 197 00:14:42,050 --> 00:14:45,800 Then I'm going to head back to a split view controller and the first thing I'm going to do is I'm going 198 00:14:45,800 --> 00:14:47,110 to get two valuables. 199 00:14:47,120 --> 00:14:53,480 One of them is going to be called brown and white brown is it brown view controller and then I have 200 00:14:53,480 --> 00:15:04,000 a valuable hinge and that is a pink view controller like that so far in my split view controller these 201 00:15:04,000 --> 00:15:05,940 two are just mere variables. 202 00:15:05,950 --> 00:15:12,100 They have no relationship with the destinations of the two seg ways in my story storyboard. 203 00:15:12,160 --> 00:15:18,190 So that's something I have to still define it and I do that in my view did lowered by saying I have 204 00:15:18,190 --> 00:15:23,650 brown to be self not view controllers. 205 00:15:23,650 --> 00:15:25,980 That's an array of view controllers. 206 00:15:26,070 --> 00:15:27,140 The 0 1. 207 00:15:27,160 --> 00:15:31,630 That is the master one as Brown's view controller. 208 00:15:31,630 --> 00:15:38,950 So I'm saying get the brown to be of the type Brown view controller from the first view controller of 209 00:15:39,310 --> 00:15:44,260 a split view controller which is true because the very first one is the brown one. 210 00:15:44,740 --> 00:15:50,170 Now forgetting the second one with a pink one we have two things a little bit differently because the 211 00:15:50,170 --> 00:15:53,510 second one actually is not the pink view controller. 212 00:15:53,560 --> 00:15:56,020 Rather it is a navigation controller. 213 00:15:56,020 --> 00:15:58,120 So let's see how we take care of that. 214 00:15:58,450 --> 00:16:05,740 I'm gonna go in here and say pink is going to be self DOD view controllers. 215 00:16:05,800 --> 00:16:08,150 The first one which is the second one. 216 00:16:08,170 --> 00:16:14,050 Essentially I'm going to give it as a you eye navigation controller. 217 00:16:14,080 --> 00:16:19,870 I know that's the case again from this UI navigation controller I'm going to say 218 00:16:22,950 --> 00:16:27,070 here get top view controller. 219 00:16:27,210 --> 00:16:33,420 I'm going to get that top view controller as a ping view controller. 220 00:16:33,420 --> 00:16:36,600 So once again from the self you controller. 221 00:16:36,600 --> 00:16:39,630 The first one is a navigation controller. 222 00:16:39,630 --> 00:16:41,580 That navigation controller. 223 00:16:41,730 --> 00:16:47,460 It's top view controller is a pink view controller and that becomes my pink one. 224 00:16:48,540 --> 00:16:52,890 Once I have the pink I could do this and this is what we have been waiting for. 225 00:16:52,890 --> 00:16:56,790 Pink Dot delegate to here. 226 00:16:58,420 --> 00:17:01,780 And since I'm trying to delegate to year I have to conform to the protocol. 227 00:17:01,800 --> 00:17:08,910 I'm going to say the protocol is changing text in pink delegate and once a conform to it I have to include 228 00:17:08,910 --> 00:17:11,610 the methods of it or it stops from it. 229 00:17:11,670 --> 00:17:15,170 And here is that method saying change takes two. 230 00:17:15,180 --> 00:17:20,520 That's all I have to have in my split view control of everything else I can delete because we don't 231 00:17:20,520 --> 00:17:20,860 agree. 232 00:17:20,940 --> 00:17:25,120 Not like that I can properly delete like that. 233 00:17:25,620 --> 00:17:27,600 So now they change the text. 234 00:17:27,600 --> 00:17:31,110 What should we do in change the text in here. 235 00:17:31,140 --> 00:17:33,730 Remember this is a function from the delegate. 236 00:17:33,750 --> 00:17:38,030 It already knows where it has to apply itself and that is the pink. 237 00:17:38,040 --> 00:17:46,720 So I'm gonna say pink dot my labor dot text becomes whatever value you receive. 238 00:17:46,860 --> 00:17:53,640 Now this is the beauty and this trend of using delegation partners in our U.S. because they split your 239 00:17:53,640 --> 00:18:01,110 controller has nothing to do with the pink or its Labor or even brown or the delegation is just a controller 240 00:18:01,110 --> 00:18:04,670 for all of these guys and the relationship between them. 241 00:18:04,800 --> 00:18:11,400 Once it is said it essentially allows you to do any kind of communication between all of these different 242 00:18:11,700 --> 00:18:12,810 view controllers. 243 00:18:12,930 --> 00:18:16,430 Which is really really powerful in many many situations. 244 00:18:16,470 --> 00:18:23,370 So now we have our brown our pink view controller automatically finding the value for its label from 245 00:18:23,370 --> 00:18:24,540 the delegation. 246 00:18:24,540 --> 00:18:30,090 The problem is nobody so far has called that delegation and that's the next thing we have to do. 247 00:18:30,090 --> 00:18:36,250 We have to go to a brown one and say here's a vendor function is called. 248 00:18:36,330 --> 00:18:39,760 We have to somehow call the delegate from the pink. 249 00:18:39,810 --> 00:18:44,400 So let me read everything else because we don't need any of those guys in here. 250 00:18:44,410 --> 00:18:48,850 We have to call the delegate from pink but pink isn't even yet. 251 00:18:48,850 --> 00:18:55,620 Pink is somewhere else in a different view controller called mine a split view controller. 252 00:18:55,690 --> 00:18:57,150 So you have to get it like this. 253 00:18:57,160 --> 00:19:02,000 I'm going to say s this view controller dot parents. 254 00:19:02,110 --> 00:19:08,160 I'm gonna get its parent independent of it I'm going to get it as my split view controller. 255 00:19:08,260 --> 00:19:15,310 So so far we found the parent of the brown one the parent of the brown one which happens to be this 256 00:19:15,310 --> 00:19:15,890 guy. 257 00:19:15,940 --> 00:19:17,640 Has someone called the pink. 258 00:19:17,770 --> 00:19:21,790 So I'm going to go in here and say the parent that pink. 259 00:19:21,990 --> 00:19:26,260 The Pink has something called delicate dot delegate. 260 00:19:26,440 --> 00:19:33,160 The delegate has some function called Change takes two and now we can enter a string or you can have 261 00:19:33,160 --> 00:19:35,330 a text field or anything that you want. 262 00:19:35,350 --> 00:19:40,570 I'm just gonna manually change it to saying this is sent from. 263 00:19:42,070 --> 00:19:48,730 Now let's go ahead and run the app and know see all of these things in action and do a quick recap and 264 00:19:48,730 --> 00:19:53,760 I'm actually going to change something in here just so we can see how it works. 265 00:19:53,830 --> 00:20:00,670 So right now when I type on the change it this label should show the message we are trying to send which 266 00:20:00,670 --> 00:20:02,730 is this is from Brown. 267 00:20:02,770 --> 00:20:05,310 It says this is sent from Brown. 268 00:20:05,430 --> 00:20:08,540 Now I'm still seeing that navigation bar over there. 269 00:20:08,540 --> 00:20:12,850 There's something I don't want to have because I don't really have a navigation happening in here. 270 00:20:12,970 --> 00:20:16,870 So you could actually get rid of that in your pink view controller. 271 00:20:16,870 --> 00:20:23,410 You could go in here and say view it Lord or actually if you will up here would be a better one. 272 00:20:24,370 --> 00:20:25,900 You will appear super. 273 00:20:25,900 --> 00:20:34,390 That view will appear through and then either I'm going to say self not navigation controller not navigation 274 00:20:34,390 --> 00:20:36,930 bar that is then. 275 00:20:37,060 --> 00:20:38,220 And that is true. 276 00:20:38,650 --> 00:20:43,790 So the moment the view Lord I want it at the moment view will be low the loading will appear. 277 00:20:44,050 --> 00:20:48,850 I'm going to get rid of the navigation bar to make sure that we don't have that you know a space being 278 00:20:48,850 --> 00:20:50,470 wasted for no reason. 279 00:20:50,470 --> 00:20:56,150 So it's rotated again and like that we have to change it and that's working like that. 280 00:20:56,290 --> 00:21:00,250 Now they say they want to change something and that's not really necessary but they want to show you 281 00:21:00,250 --> 00:21:03,030 how it works and when go twice with your controller. 282 00:21:03,310 --> 00:21:07,310 And I'm going to say we always do the delegation to self. 283 00:21:07,480 --> 00:21:10,780 Is that a way to do a delegation to something other than self. 284 00:21:10,820 --> 00:21:12,640 And that's absolutely possible. 285 00:21:12,640 --> 00:21:19,030 So in this case I'm going to say pink delegates it's tasks to Brown. 286 00:21:19,210 --> 00:21:20,770 Now here's what happens. 287 00:21:20,890 --> 00:21:25,130 You know if you want to do this I would suggest that you actually pay attention to it and then show 288 00:21:25,130 --> 00:21:29,970 it to do it on your own is saying that the delegation of pink should go to Brown. 289 00:21:29,980 --> 00:21:34,450 And obviously it's saying Well Brown is not conforming to that you know method. 290 00:21:34,480 --> 00:21:42,430 So I'm going to say Brown has to conform to changing text in pink delegate rich. 291 00:21:42,430 --> 00:21:43,690 Now that is happening. 292 00:21:43,690 --> 00:21:50,710 So in a speech you control this area is going to go away now since I'm delegating to Brown now and the 293 00:21:50,710 --> 00:21:56,710 Brown is going to take care of the delegation method then this find my split view control it doesn't 294 00:21:56,710 --> 00:21:57,580 need to do that. 295 00:21:57,580 --> 00:22:02,950 So I'm going to get rid of that and since this is a function from there I'm going to get rid of that 296 00:22:03,040 --> 00:22:03,520 as well. 297 00:22:04,390 --> 00:22:06,730 So once again now we have the brown and pink. 298 00:22:06,730 --> 00:22:07,270 I'll be fine. 299 00:22:07,270 --> 00:22:13,930 BROWN I'm being obviously a pink delegates to Brown and Brown has to take care of the everything that 300 00:22:13,930 --> 00:22:15,920 is in the delegation in the protocol. 301 00:22:15,960 --> 00:22:21,130 And when I go to Brown and the Brown says well you're trying to conform to this but you are not taking 302 00:22:21,130 --> 00:22:22,420 care of all the methods. 303 00:22:22,420 --> 00:22:23,890 Are you sure you want to do that. 304 00:22:24,220 --> 00:22:29,140 I'm going to say no I won't actually have this method and I'm going to say in this method I want to 305 00:22:29,140 --> 00:22:31,520 change the text routine. 306 00:22:31,570 --> 00:22:34,270 Somebody else got somebody else. 307 00:22:34,300 --> 00:22:38,830 Once again is not here is not in the Brown is not even in there. 308 00:22:38,830 --> 00:22:48,190 Brown's parents it is in the Brown's parents are their child which is this guy song the copy that say 309 00:22:48,490 --> 00:22:52,660 self parent has a split view controller that pinch. 310 00:22:52,840 --> 00:22:54,340 That's my labor. 311 00:22:54,350 --> 00:22:58,870 That text becomes whatever value we find. 312 00:22:59,770 --> 00:23:04,650 So if run the application it should work exactly identically to what it used to work. 313 00:23:04,720 --> 00:23:09,890 Just a minute ago and let's see that we change and that works. 314 00:23:09,890 --> 00:23:15,820 Now I know I when I deviated away from this split view controller but they found it a good practice 315 00:23:15,820 --> 00:23:19,660 for us just to get a sense of none of these things are set on a stone. 316 00:23:19,660 --> 00:23:26,050 You don't always have to have your delegation to point to the self and you don't always have to have 317 00:23:26,050 --> 00:23:31,250 their methods in there to view controllers that they have a Segway between them. 318 00:23:31,300 --> 00:23:32,310 You can do it. 319 00:23:32,350 --> 00:23:38,380 The goal of this course and essentially the goal of doing better programming is getting to know so many 320 00:23:38,380 --> 00:23:44,320 different methods so you can mix and match them and find the best solution that you can think of going 321 00:23:44,320 --> 00:23:49,780 back to the original discussion of this less than a split view contours are very useful for situations 322 00:23:49,780 --> 00:23:56,140 where you want to control one you controller with another one primarily use when you have so many many 323 00:23:56,140 --> 00:24:02,770 items in like a table view in an e-mail application that each of them has a lot of details on the right 324 00:24:02,770 --> 00:24:03,670 side of the screen. 325 00:24:03,970 --> 00:24:09,910 So we will see that far more in advance and more details when we talk about table view controllers in 326 00:24:09,910 --> 00:24:11,040 the next section. 327 00:24:11,080 --> 00:24:16,600 But for now you get a sense of how is with new controllers work and how you can essentially benefit 328 00:24:16,600 --> 00:24:17,330 from them. 329 00:24:17,470 --> 00:24:18,150 And. 330 00:24:18,250 --> 00:24:19,420 Yeah let's keep it up to here. 331 00:24:19,430 --> 00:24:20,620 I see you in the next lesson.