Hey everybody what's going on this is Caleb with slopes dot com.
And in this video we're going to set up the delegate for our table view in our acts so that we can use
a lot of those table view delegate methods that we will need for like selecting a cell for instance.
OK so we're going to go ahead and pull open our project here and we're going to set it up right now.
It's not very hard but what we do need to do is beneath bind elements we're going to go ahead and call
table view.
Our X got set.
DELEGATE.
OK it's that easy.
We're going to set the delegate to be self just like you would for a normal table view.
But after that we're going to go ahead and call add disposable to and pass it into the Dispose bag.
OK.
Because it does require that.
So our delegate is now set as ourself.
But you'll notice it's you know being being mad at us it's not being very friendly so we're going to
go ahead and conform to your table view delegate like so.
And if we go ahead and build this you'll notice that ergos way.
Now if we go down in our class to the very bottom we can go ahead and call did select row at index path
so we can access all of those same delegate methods that we need to just without the issues.
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
basically going to use it to help us load a certain web site.
Right because each cell has a repo you l.
So go ahead and type guard let's sell.
And that's going to be equal to Table View dot cell for road index path.
And you notice I'm using guard let Because this cell comes in as optional so the index path of course
is index.
And if we don't get that we're going to say.
Else.
Well just return because this function isn't asking for anything else.
So I'm assuming though that we do get a cell.
We should be able to print sell sell datt repo your l.
But you know what we're not actually casting this as a search cell so go ahead and cast it as a search
sell.
And now we should be able to get access to the repo.
You r l although you know what.
No no no that's right because we set it to be a private variable.
So let's actually set it to be public with a private sector.
All right.
So it's publicly available but privately set.
So now we should be able to go in and say well let's build an Since we update or a code.
Ok so sell dot repo your.
There we go.
Now we have access although that is privately set and nice and safe we're going to go ahead and build
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
this particular repository.
So here's our simulator Let's enter our search field and let's see if we get.
Okay good.
So let's search for our X Swift again.
There we go.
And when I select it we print out the repositories you are l look at that.
How cool is that.
And you know obviously you can copy this you can go paste it into safari and test it for yourself but
it works.
That's exactly what we need.
So very very cool.
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
going to use some of these scrolls you delegate methods that are just part of table view to basically
just determine that when the table view scrolls it's going to end editing on the textfield.
So just go ahead and type scroll view did scroll.
OK.
And if the table view scrolls at all we're just going to call and editing on the view.
So go ahead and type view and editing for it to be true and that's basically going to end anything that
is in edit mode it'll turn it off edit mode so it'll hide the keyboard it'll do all that stuff which
is really cool.
That's exactly what we want let's think.
Is there anything else we got to do.
You know I would like it so that when you push the return button in our app like so like let's say I
typed our swift oops I got to show the actual keyboard.
I want to make it so that when I push return it's going to hide the keyboard and you know what it looks
like it's already doing that.
So let's go ahead and just see our act swift if I push return.
It's already hiding the keyboard.
I think maybe we set that up in our textfield class.
Oh we didn't.
But interesting it's hiding automatically I don't believe it will do that on a device.
So I'm actually going to just totally make sure that it does by conforming to you I textfield delegate
like so and then down here below the table view stuff we're going to go ahead and just say textfield
should return and go ahead and call and editing as well for it to be true and then return it true.
And that will basically set it up so that when you push return on the textfield it's going to end editing
and hide the keyboard build and run.
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
going to set up an extension of you eye view controller that's going to allow us to present a Safari
web view controller on the top of this view controller so that we can view all of our cool cells and
information.
So let's try it out.
Arc's swift and let's push return.
And it hides the keyboard.
Very cool.
Let's test the scrolling one.
If I bring up the keyboard here let's scroll and it hides the keyboard that's exactly what I wanted
it to do.
Beautiful.
So very cool.
Let's go ahead and let's move on to the next video where we're going to present our SRF Safari view
controller and I will be finished.
Let's go ahead and let's do that now.