1 00:00:00,300 --> 00:00:08,370 Right, so so far, we've built our authentic authentication screen, but we're not we don't have a 2 00:00:08,370 --> 00:00:10,660 way of actually showing that to the end user. 3 00:00:11,310 --> 00:00:13,220 So we want to show this auth view controller. 4 00:00:13,230 --> 00:00:14,190 How do we go about it? 5 00:00:14,760 --> 00:00:19,980 Well, what we're going to do is open up our view controller and I'm going to copy and paste some code 6 00:00:19,980 --> 00:00:21,970 that I've got in the premade app. 7 00:00:22,770 --> 00:00:27,500 And what we're going to do is grab the authentication from Firebase. 8 00:00:27,510 --> 00:00:32,250 So if I look at my code over here, we're going to import Firebase Auth. 9 00:00:36,350 --> 00:00:45,170 Like, so and that should give us access to the authentication, so this off is a firebase feature is 10 00:00:45,170 --> 00:00:49,970 going to grab the current off object authentication object and it's going to look for the current user. 11 00:00:50,570 --> 00:00:55,970 If that user is nil, then we are going to grab the view controller from the storyboard. 12 00:00:56,220 --> 00:00:58,040 So this is how we access the storyboard. 13 00:00:58,550 --> 00:01:00,230 We access self-taught storyboard. 14 00:01:00,500 --> 00:01:06,650 And then we say, I want you to make the view controller and I want you to grab the one with this identifier 15 00:01:06,890 --> 00:01:09,500 so we don't actually have that plugged in right now. 16 00:01:09,930 --> 00:01:14,940 So let's go to our main storyboard and give that identifier to this auth view controller. 17 00:01:15,890 --> 00:01:16,790 So here we go. 18 00:01:16,820 --> 00:01:19,880 The storyboard I.D., I believe this is. 19 00:01:21,390 --> 00:01:24,660 And that on pressing enter hit command is to save it. 20 00:01:25,140 --> 00:01:26,350 So that's over on the top, right? 21 00:01:26,370 --> 00:01:27,900 We've put in the Earth view controller. 22 00:01:28,380 --> 00:01:32,850 Now, this shouldn't crash because that is a potential place where you could crash. 23 00:01:34,140 --> 00:01:34,990 What are we going to do? 24 00:01:35,010 --> 00:01:40,110 We're going to get the navigation controller that we currently have and we're going to present what 25 00:01:40,110 --> 00:01:44,750 we the orfeu controller, except you know what the problem is, right? 26 00:01:45,280 --> 00:01:47,160 If we look at our storyboard, what's missing? 27 00:01:48,100 --> 00:01:49,910 There is no navigation controller. 28 00:01:50,370 --> 00:01:52,050 There is only a view controller. 29 00:01:52,060 --> 00:01:54,180 That's the initial entry point. 30 00:01:55,080 --> 00:01:58,800 So we are going to drop in a NAV controller like that. 31 00:02:00,360 --> 00:02:05,140 We are going to remove this other view controller because we don't need it anymore. 32 00:02:06,420 --> 00:02:11,400 So if you just tap the bar at the top or tap the controller, I hate this. 33 00:02:11,400 --> 00:02:15,620 Sometimes if you press backspace, it works or command backspace. 34 00:02:15,630 --> 00:02:17,450 But in this particular case, it won't go away. 35 00:02:19,660 --> 00:02:20,440 Can you believe that? 36 00:02:21,460 --> 00:02:26,290 Anyway, I'll just leave it sitting there for now, what we're going to do is tap the nav control and 37 00:02:26,290 --> 00:02:32,580 the navigation control and we're going to make that the primary initial view controller. 38 00:02:32,840 --> 00:02:36,120 So over on the right is initial view controller is selected. 39 00:02:36,650 --> 00:02:41,380 So that's going to go into the table view and off it goes and does its thing. 40 00:02:42,850 --> 00:02:43,350 OK. 41 00:02:43,720 --> 00:02:49,550 So this route view controller, I'm just going to what am I going to do here? 42 00:02:49,780 --> 00:02:54,280 What I'm going to have to do is implement a table view controller. 43 00:02:55,250 --> 00:02:59,330 So this actually loads because watch what happens if I press play on this. 44 00:03:01,360 --> 00:03:05,830 I think we're going to get some kind of crash potentially. 45 00:03:07,200 --> 00:03:10,980 I mean, I've promised you a crash, and now if I don't give you one, you're going to be disappointed, 46 00:03:10,980 --> 00:03:11,250 right? 47 00:03:12,890 --> 00:03:15,780 But that is working, OK? 48 00:03:16,070 --> 00:03:21,740 It is working because it's using a standard UI table view controller for this table view. 49 00:03:23,620 --> 00:03:26,330 So we have a slight problem here. 50 00:03:26,740 --> 00:03:33,670 What we have here is a table view controller and what we actually want is still the table view. 51 00:03:34,210 --> 00:03:43,780 But we need to have a and if I look at the built project, we need to have a box that allows us to type 52 00:03:43,780 --> 00:03:44,530 our message. 53 00:03:44,860 --> 00:03:50,450 Now, if you have a table view controller, that's all you have on that screen is a table view. 54 00:03:51,700 --> 00:03:58,540 What we have to do is convert this screen to a regular view controller that implements everything a 55 00:03:58,540 --> 00:04:00,520 table view requires. 56 00:04:01,160 --> 00:04:04,120 OK, so what I'm going to do is go back to our project. 57 00:04:04,570 --> 00:04:10,120 And if you follow along with this, what I'm going to do is remove the root view controller. 58 00:04:11,530 --> 00:04:14,230 At least I'm going to try and remove the root view controller. 59 00:04:16,060 --> 00:04:17,200 So let's go over here and try it. 60 00:04:17,410 --> 00:04:17,890 There we go. 61 00:04:18,010 --> 00:04:18,460 It's gone. 62 00:04:19,150 --> 00:04:22,830 And now I'm going to just put in a plain view controller. 63 00:04:22,840 --> 00:04:27,220 Actually, I don't need to I can use our old one content so I can just bring this up here. 64 00:04:27,760 --> 00:04:29,050 Now we need to connect them. 65 00:04:29,050 --> 00:04:36,220 So control click from the NAV controller to the View controller and we are going to have a manual. 66 00:04:36,220 --> 00:04:37,400 No, not a manual Segway. 67 00:04:37,400 --> 00:04:40,660 We're going to have relationship Segway route view controller. 68 00:04:41,350 --> 00:04:43,300 OK, so now that is the route. 69 00:04:43,720 --> 00:04:46,870 If I click the view controller itself and then at the top. 70 00:04:46,870 --> 00:04:47,260 Right. 71 00:04:47,770 --> 00:04:51,200 Just make sure that we have that view controller selected. 72 00:04:51,670 --> 00:04:53,170 Now everything should be fine. 73 00:04:53,380 --> 00:04:55,600 OK, so we've got rid of the table view for now. 74 00:04:55,840 --> 00:04:58,810 We will come back to that when we need to create it. 75 00:04:59,890 --> 00:05:02,940 OK, so let's go back to our view controller. 76 00:05:03,610 --> 00:05:09,550 We have this function we just set up to raise the Earth View controller and now, of course, we need 77 00:05:09,550 --> 00:05:12,240 to call it check the current user. 78 00:05:12,700 --> 00:05:15,160 So let's play that in the iPod Touch. 79 00:05:15,160 --> 00:05:15,990 Seventh gen. 80 00:05:17,380 --> 00:05:18,070 There it is. 81 00:05:21,870 --> 00:05:22,590 Is that building? 82 00:05:23,160 --> 00:05:26,010 Yes, it is building 66 tasks I don't understand. 83 00:05:27,300 --> 00:05:33,470 There weren't that many, and I hopefully won't get a crash, but if we do, we'll be able to fix it, 84 00:05:33,480 --> 00:05:34,140 obviously. 85 00:05:36,150 --> 00:05:40,560 Oh, yes, there is a crash here, so we have an uncaught exception. 86 00:05:42,030 --> 00:05:42,900 What does this say? 87 00:05:43,800 --> 00:05:48,180 This class is not cleverly cutting, applying for the key email address input. 88 00:05:49,360 --> 00:05:50,810 Interesting error. 89 00:05:51,330 --> 00:05:52,320 I'm not sure what that is. 90 00:05:52,860 --> 00:05:57,840 So if we scroll down to the log file, uncaught exception. 91 00:05:57,840 --> 00:05:58,830 Unknown key. 92 00:06:02,420 --> 00:06:10,430 Is that something to do with let's stop it running, so it said something about email address and the 93 00:06:10,430 --> 00:06:15,170 key is if we tap that box and go over to the properties on the right. 94 00:06:19,250 --> 00:06:21,710 That's very, very interesting. 95 00:06:21,920 --> 00:06:27,440 I'm not sure what it's playing at, so I'm going to go look at my finished project here and this is 96 00:06:27,440 --> 00:06:36,350 a good tip for you if you're ever in this situation, is to go look at your old projects and see what 97 00:06:36,350 --> 00:06:39,100 you actually did in those particular old projects. 98 00:06:39,560 --> 00:06:43,940 So I'm going to look at the overview controller because that's where we have the issue to do. 99 00:06:43,970 --> 00:06:44,570 There it is. 100 00:06:48,700 --> 00:06:54,220 And where are our buttons, I mean, functions are all good, that's fine. 101 00:06:56,130 --> 00:07:00,610 Let's go to the story board and let's go to the e-mail address, what do we have here? 102 00:07:00,900 --> 00:07:05,450 We have the content type email address and no keyboard type. 103 00:07:06,180 --> 00:07:10,510 Perhaps it's something to do with the idea of the controller. 104 00:07:10,530 --> 00:07:11,040 I don't know. 105 00:07:11,940 --> 00:07:13,290 Let's have a look. 106 00:07:13,290 --> 00:07:13,680 See. 107 00:07:16,040 --> 00:07:17,450 So Northview controller. 108 00:07:19,440 --> 00:07:20,700 We have the story board I. 109 00:07:20,910 --> 00:07:25,710 D perhaps we should click you storyboarded on the right side there. 110 00:07:27,000 --> 00:07:32,730 Let's play that one again and see what kind of errors that's going to throw at us while still waiting 111 00:07:32,730 --> 00:07:33,220 for it to load. 112 00:07:33,240 --> 00:07:34,950 This is a great app, self-control. 113 00:07:35,370 --> 00:07:40,590 If you browse social media, watch YouTube too much, you can block yourself on your Mac for a little 114 00:07:40,590 --> 00:07:46,250 while as long as you set it for and you absolutely cannot access them even if you reboot. 115 00:07:46,650 --> 00:07:48,750 So it's really good at keeping you focused. 116 00:07:51,410 --> 00:07:56,630 And it's unknown, key exception you, I view controller, this class is not key value coding compliant 117 00:07:56,630 --> 00:07:59,870 for the key email address input. 118 00:08:00,530 --> 00:08:02,270 Now, this is a very interesting area. 119 00:08:02,270 --> 00:08:03,880 I've never seen one like this before. 120 00:08:04,490 --> 00:08:07,040 I'm going to go away and figure it out and then I'll let you know. 121 00:08:08,840 --> 00:08:13,720 What a pain it was, this really obscure bug that was making that error for me. 122 00:08:14,540 --> 00:08:15,890 I'll show you the solution. 123 00:08:15,920 --> 00:08:20,000 You probably won't have this error, though, if you select the top bar of your view controller and 124 00:08:20,000 --> 00:08:27,550 then you go over to the class inspector where you've selected orfeu controller down below that. 125 00:08:27,560 --> 00:08:34,820 This should be clicked inherit module from Target, OK, or you select the module in that drop down 126 00:08:34,820 --> 00:08:35,170 menu. 127 00:08:36,440 --> 00:08:39,290 That was why we were getting that very strange error. 128 00:08:39,590 --> 00:08:44,750 Now, of course, when I hit play, we're going to see exactly what we should see, which is it checks 129 00:08:44,750 --> 00:08:45,730 for the authentication. 130 00:08:45,740 --> 00:08:50,310 There is no user logged in, so it presents what we expect it to present. 131 00:08:50,660 --> 00:08:56,660 Now, there are a couple of things wrong with this screen, as you can see, because I can hold it and 132 00:08:56,660 --> 00:08:57,500 move it up and down. 133 00:08:57,620 --> 00:08:58,610 And, of course, it disappears. 134 00:08:58,620 --> 00:08:59,660 We can't bring it back up. 135 00:08:59,990 --> 00:09:06,140 But because of that action that forgot password is a little bit too low, if you ask me. 136 00:09:06,140 --> 00:09:10,910 So what I'm going to do is increase that to about 30. 137 00:09:11,390 --> 00:09:11,990 Um. 138 00:09:13,980 --> 00:09:21,290 Zero, yes, or minus 10, we get shifted up a little bit now, OK? 139 00:09:21,340 --> 00:09:28,030 And then also I'm going to select email address and password and I'm just going to change their backgrounds 140 00:09:28,030 --> 00:09:32,860 to white because a green background doesn't look that great, does it? 141 00:09:33,850 --> 00:09:36,490 So there's the view background. 142 00:09:36,490 --> 00:09:38,000 Do we have an item background? 143 00:09:38,020 --> 00:09:38,330 No. 144 00:09:38,860 --> 00:09:45,910 So we'll go to the view background and we'll just use white, OK, and then make sure because I did 145 00:09:45,910 --> 00:09:47,730 change some stuff to see what's going on here. 146 00:09:48,130 --> 00:09:54,060 Keyboard type and email address will have keyboard type email for that one too. 147 00:09:54,970 --> 00:09:59,440 And now we're going to hit play on that and it should look somewhat better. 148 00:10:02,840 --> 00:10:08,540 And there we have it, so now if I go to email address, it doesn't show the keyboard it did last time, 149 00:10:08,540 --> 00:10:13,880 of course, when I wasn't recording the simulator can be a little bit weird like that. 150 00:10:14,300 --> 00:10:22,700 It just stops showing things on occasion so we can go to Eyo, maybe keyboard toggle software, keyboards, 151 00:10:22,700 --> 00:10:28,340 we can hit Command K and it will show us and you'll notice the email address keyboard has an app there 152 00:10:28,340 --> 00:10:31,910 and it gives clicks just like real iOS. 153 00:10:32,240 --> 00:10:35,720 And if we go to password you'll notice just the app disappears. 154 00:10:36,410 --> 00:10:36,770 Right. 155 00:10:38,150 --> 00:10:39,790 And the password doesn't asterisk. 156 00:10:39,820 --> 00:10:43,370 So I guess that's something we have to change now. 157 00:10:43,370 --> 00:10:44,290 How do we do that? 158 00:10:44,300 --> 00:10:45,890 Let's go over to password. 159 00:10:47,300 --> 00:10:50,030 We have content type password. 160 00:10:50,840 --> 00:10:56,330 I was pretty sure I knew where this was smart, quote, smart dashes. 161 00:10:58,260 --> 00:11:04,680 A secure text entry, they would go right at the bottom, you just toggle that on and now when we hit 162 00:11:04,680 --> 00:11:08,790 play, we should get that secure entry with the asterisks. 163 00:11:10,710 --> 00:11:16,440 So in we go, and you don't know what I'm pressing because those little dots appear right. 164 00:11:16,460 --> 00:11:18,140 So I think we'll end that one there.