Welcome back again.
In this listen I'm going to show you how to use a mass their detail template application.
And that's the one that you find when you start a new application in X quote and there isn't a lifted
intentionally for now is I want others to have a better understanding of how table views work and how
the different methods they come together.
I personally am not a big fan of using templates anyway because I kind of don't understand how they
are doing things.
And I would rather if I know exactly how I put an application together but in case you ever wanted to
do a quick and dirty version of a table view you could essentially use that.
So I'm going to go into export and yet I'm going to start a new application called a master detail application
type and I'm going to call it master detail app and what it essentially does is it makes a table view
with a detailed view controller as well as a split view controller.
So it is a split view controller such as this one that the Smith view controller has two pieces of view
controller one of them being a navigation controller with a table view the other one being in navigation
controller with a detailed view controller.
So every time you tap on any item in the master it shows you the details of that in the other view.
Let me run the application first and then I'm going to try to explain to you how this thing is put together
and you can take it from there.
So once the application notes you have a table view you have an add by then and you have an edit by
then.
And if you rotate your view you will essentially have only the table view and the master viewpoint aura
is essentially collapsed or hidden.
If you type on the master that appears in here and you can again see your table view in the table view
everything you top on the plus within it does nothing but adding the current time as one of the setters
and into your array as you add them it constant the outdoors and every time the top on any of doors
is essentially going to take you to the detail the you controller of those details if I go back to master
click in here becoming there and we see that obviously this is happening through our navigation controller
and the detail is being passed through a Segway and we're calling a Segway every time with top on one
of the items from our cells of our table view now it's going here in the master view controller you
really don't have anything that is all that different than what we have done in the past in the view
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
through this I'm going to format the court so it becomes more familiar both for myself and for you.
So that's the left bar but an item then after that we have the right what about an item and then depending
on the orientation of the device we decide whether we have a split and if we have a split which one
should be the detail view controller I will come back to this in a bit within a half things such as
inserting a new object which essentially in sets a new data into the objects objects is the array that
we are using for everything.
This is what we usually called Cities are a.
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
off the table view we usually did this in a slightly differently we added that to our array and we reloaded
our table view by inserting a row into a table view you end up having a little bit of an animation which
is something that is nice and you end up you know you end up seeing a bit of an animation here that's
when we press in here we see that little animation if you were just to reload the table view they would
all just appear together.
So that's the one good takeaway from this.
The next thing is preparing for a Segway which if the Segway is the sure detail we find then they expand
on the most important part of it is this one we send an item to the other side which is the detailed
view controller in terms of the data source for a table view we have one section we have as many objects
in our array and for the cell for right index card we have a cell with an identifier called cell and
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
I can edit role which is the one that allows us to delete or remove stuff and in the comments editing
a slide which is something we did I think in just the listener go the video editing is night if it is
delete then we remove the objects from the array we delete the rules just like what we had done before
and we are not really doing anything in the insert just yet so that's essentially how our master view
countries put together in the detail view controller things are actually even easier we have one table
that shows us the value that we have on the detail item in that item is the one that gets passed on
between the master view controller and the detail view controller.
So when the view lords essentially we say configure view fish configuration essentially runs that finds
the detail item and from the detail item essentially populates the value on the label.
The only thing that might be new for you guys is here in the app delegate.
If you go in here and gets rid of everything we don't need in the app delegate did finish launching
application with options.
We find that a split view controller and we delegate from it to here.
By doing that we get access to this one function let me delete everything else because we don't really
need them.
So the only function that really matters is this one.
Let me read for my dad 1 properly as well.
So we have a better understanding of what's going on.
This one is called collapse secondary.
So the reason we have that is if you want to be able to collapse the second of view controller in a
situation like this.
This is a split view controller right now but one part of their split view controller is actually hidden
or is collapsed.
Then we top on the mask that it actually appears in here and that's the purpose of collapsing a cyclone
3 part of a split view controller.
I actually encourage you to spend some time on this application.
Like I said I personally have never used this application for any real life situation simply because
I want to know where things are and I want to know why I have called something in a certain way.
Obviously calling something objects doesn't really cut it for you.
You need to call it based on the objects that you have and then based on that array you might want to
do things.
Same thing applies to pretty much everything in this application.
But in saying that because it's such a good design and everything functions well in it I actually suggest
that you spend a little time going through every little bit of it perhaps breaking all of these connections
or deleting all of these in the storyboard remaking them on your own and rewriting the code for every
part of it.
So you have a very good understanding of everything that's happening in here.
This is kind of our last lesson when it comes to table views on table view controllers.
By now you should be able to do most everything that is doable within a table view.
So with that in mind.
Let's keep it up to here and I'll move on to our next lesson which I think is an exercise.
And like I said I encourage you to spend some time on this application and get a sense of how they put
things together.
Any part of it that is unfamiliar to you or you don't know what happens.
Try to google it or drop me an email.
I will get back to you wait you know what is happening in that place.