1
00:00:07,850 --> 00:00:11,060
Hey everybody what's going on this is Caleb with slopes dot com.

2
00:00:11,070 --> 00:00:17,250
And in this video we're going to set up the delegate for our table view in our acts so that we can use

3
00:00:17,310 --> 00:00:22,780
a lot of those table view delegate methods that we will need for like selecting a cell for instance.

4
00:00:22,920 --> 00:00:28,620
OK so we're going to go ahead and pull open our project here and we're going to set it up right now.

5
00:00:28,620 --> 00:00:34,160
It's not very hard but what we do need to do is beneath bind elements we're going to go ahead and call

6
00:00:34,170 --> 00:00:35,540
table view.

7
00:00:35,670 --> 00:00:37,080
Our X got set.

8
00:00:37,080 --> 00:00:38,190
DELEGATE.

9
00:00:38,390 --> 00:00:39,240
OK it's that easy.

10
00:00:39,240 --> 00:00:43,580
We're going to set the delegate to be self just like you would for a normal table view.

11
00:00:43,590 --> 00:00:53,950
But after that we're going to go ahead and call add disposable to and pass it into the Dispose bag.

12
00:00:54,290 --> 00:00:54,820
OK.

13
00:00:55,020 --> 00:00:56,840
Because it does require that.

14
00:00:56,910 --> 00:01:00,070
So our delegate is now set as ourself.

15
00:01:00,090 --> 00:01:06,630
But you'll notice it's you know being being mad at us it's not being very friendly so we're going to

16
00:01:06,630 --> 00:01:11,580
go ahead and conform to your table view delegate like so.

17
00:01:11,850 --> 00:01:16,230
And if we go ahead and build this you'll notice that ergos way.

18
00:01:16,410 --> 00:01:24,030
Now if we go down in our class to the very bottom we can go ahead and call did select row at index path

19
00:01:24,030 --> 00:01:29,800
so we can access all of those same delegate methods that we need to just without the issues.

20
00:01:29,800 --> 00:01:36,000
OK so now what we're going to do is we're going to create a cell or an instance of a cell and we're

21
00:01:36,000 --> 00:01:40,490
basically going to use it to help us load a certain web site.

22
00:01:40,500 --> 00:01:43,230
Right because each cell has a repo you l.

23
00:01:43,260 --> 00:01:45,770
So go ahead and type guard let's sell.

24
00:01:46,290 --> 00:01:51,800
And that's going to be equal to Table View dot cell for road index path.

25
00:01:51,810 --> 00:01:57,720
And you notice I'm using guard let Because this cell comes in as optional so the index path of course

26
00:01:57,720 --> 00:01:59,250
is index.

27
00:01:59,250 --> 00:02:01,420
And if we don't get that we're going to say.

28
00:02:01,450 --> 00:02:03,070
Else.

29
00:02:03,360 --> 00:02:06,750
Well just return because this function isn't asking for anything else.

30
00:02:06,810 --> 00:02:09,710
So I'm assuming though that we do get a cell.

31
00:02:09,810 --> 00:02:16,890
We should be able to print sell sell datt repo your l.

32
00:02:16,890 --> 00:02:22,290
But you know what we're not actually casting this as a search cell so go ahead and cast it as a search

33
00:02:22,290 --> 00:02:22,930
sell.

34
00:02:23,130 --> 00:02:27,300
And now we should be able to get access to the repo.

35
00:02:27,330 --> 00:02:30,040
You r l although you know what.

36
00:02:30,050 --> 00:02:33,770
No no no that's right because we set it to be a private variable.

37
00:02:33,780 --> 00:02:38,540
So let's actually set it to be public with a private sector.

38
00:02:38,550 --> 00:02:38,820
All right.

39
00:02:38,820 --> 00:02:41,530
So it's publicly available but privately set.

40
00:02:41,850 --> 00:02:47,990
So now we should be able to go in and say well let's build an Since we update or a code.

41
00:02:47,990 --> 00:02:50,940
Ok so sell dot repo your.

42
00:02:50,990 --> 00:02:51,290
There we go.

43
00:02:51,290 --> 00:02:57,560
Now we have access although that is privately set and nice and safe we're going to go ahead and build

44
00:02:57,560 --> 00:03:02,660
and run this and we're going to go test it out to see if we are actually able to print the U or L for

45
00:03:02,660 --> 00:03:04,670
this particular repository.

46
00:03:04,670 --> 00:03:10,700
So here's our simulator Let's enter our search field and let's see if we get.

47
00:03:10,700 --> 00:03:11,440
Okay good.

48
00:03:11,450 --> 00:03:14,670
So let's search for our X Swift again.

49
00:03:14,690 --> 00:03:15,230
There we go.

50
00:03:15,230 --> 00:03:21,070
And when I select it we print out the repositories you are l look at that.

51
00:03:21,110 --> 00:03:22,620
How cool is that.

52
00:03:22,680 --> 00:03:27,770
And you know obviously you can copy this you can go paste it into safari and test it for yourself but

53
00:03:27,770 --> 00:03:28,490
it works.

54
00:03:28,490 --> 00:03:30,100
That's exactly what we need.

55
00:03:30,110 --> 00:03:32,240
So very very cool.

56
00:03:32,300 --> 00:03:37,820
Let's go ahead and let's cancel that let's close the application and what we're going to do now is we're

57
00:03:37,820 --> 00:03:42,590
going to use some of these scrolls you delegate methods that are just part of table view to basically

58
00:03:42,590 --> 00:03:48,020
just determine that when the table view scrolls it's going to end editing on the textfield.

59
00:03:48,020 --> 00:03:51,800
So just go ahead and type scroll view did scroll.

60
00:03:52,040 --> 00:03:52,630
OK.

61
00:03:52,880 --> 00:03:56,710
And if the table view scrolls at all we're just going to call and editing on the view.

62
00:03:56,720 --> 00:04:03,860
So go ahead and type view and editing for it to be true and that's basically going to end anything that

63
00:04:03,860 --> 00:04:09,320
is in edit mode it'll turn it off edit mode so it'll hide the keyboard it'll do all that stuff which

64
00:04:09,320 --> 00:04:10,490
is really cool.

65
00:04:10,490 --> 00:04:13,520
That's exactly what we want let's think.

66
00:04:13,520 --> 00:04:15,610
Is there anything else we got to do.

67
00:04:15,830 --> 00:04:23,330
You know I would like it so that when you push the return button in our app like so like let's say I

68
00:04:23,330 --> 00:04:26,920
typed our swift oops I got to show the actual keyboard.

69
00:04:27,170 --> 00:04:31,220
I want to make it so that when I push return it's going to hide the keyboard and you know what it looks

70
00:04:31,220 --> 00:04:32,450
like it's already doing that.

71
00:04:32,480 --> 00:04:36,530
So let's go ahead and just see our act swift if I push return.

72
00:04:36,530 --> 00:04:37,670
It's already hiding the keyboard.

73
00:04:37,670 --> 00:04:41,210
I think maybe we set that up in our textfield class.

74
00:04:41,400 --> 00:04:42,120
Oh we didn't.

75
00:04:42,140 --> 00:04:46,890
But interesting it's hiding automatically I don't believe it will do that on a device.

76
00:04:46,910 --> 00:04:53,320
So I'm actually going to just totally make sure that it does by conforming to you I textfield delegate

77
00:04:54,370 --> 00:05:02,250
like so and then down here below the table view stuff we're going to go ahead and just say textfield

78
00:05:02,740 --> 00:05:12,190
should return and go ahead and call and editing as well for it to be true and then return it true.

79
00:05:12,460 --> 00:05:16,120
And that will basically set it up so that when you push return on the textfield it's going to end editing

80
00:05:16,120 --> 00:05:17,820
and hide the keyboard build and run.

81
00:05:17,820 --> 00:05:24,550
Let's go check it out and then we'll be able to move on to our one of our final videos where we're basically

82
00:05:24,550 --> 00:05:29,980
going to set up an extension of you eye view controller that's going to allow us to present a Safari

83
00:05:29,980 --> 00:05:36,670
web view controller on the top of this view controller so that we can view all of our cool cells and

84
00:05:36,670 --> 00:05:37,450
information.

85
00:05:37,600 --> 00:05:38,790
So let's try it out.

86
00:05:38,800 --> 00:05:41,520
Arc's swift and let's push return.

87
00:05:41,800 --> 00:05:42,960
And it hides the keyboard.

88
00:05:42,970 --> 00:05:43,800
Very cool.

89
00:05:43,900 --> 00:05:46,090
Let's test the scrolling one.

90
00:05:46,270 --> 00:05:52,330
If I bring up the keyboard here let's scroll and it hides the keyboard that's exactly what I wanted

91
00:05:52,330 --> 00:05:52,930
it to do.

92
00:05:52,930 --> 00:05:53,850
Beautiful.

93
00:05:53,950 --> 00:05:55,520
So very cool.

94
00:05:55,540 --> 00:05:59,950
Let's go ahead and let's move on to the next video where we're going to present our SRF Safari view

95
00:05:59,950 --> 00:06:02,990
controller and I will be finished.

96
00:06:03,010 --> 00:06:04,090
Let's go ahead and let's do that now.
