Tip:
Highlight text to annotate it
X
step three hundred jump across to the storyboard
here's the problem we have right now
we have multiple view controllers in our storyboard we have no view controller
class files
international project which means there's nowhere to write
uh... own custom code
we need to provide our own
view controller dot paging dot and files
and put them up took each of the scenes that we want to write custom code for
never think about it what it means is that i need to add some custom class
files
for the table view control of the will show our
table view photos
for this view control of the wall
displaying an individual photo
and for this you control which will show
information
about the individual photo
so i'd argue this popped up to the bombing you
we're going to click new file
when adding new class but this time it will be a
you i interview controller subclass so
cup attached
you argue controller subclass
acquit next
for the first one i'm gonna provide is for our
table view controller
the one that displays the actual list of photos that we have
and that's not just a generic you argue controller right now it's a you like
table view control that's what we dragged onto the storyboard so that's
what i need to inherit from
so go to give it a name i'm going to call it
photos
table view controller
and then take care with the
casing here
because what the story board will actually do
is separate your uppercase words and make it look attractive when you're
looking at the story board this is what will appear on the dark
now very important before i created
i wanna make sure both of these checkboxes are unchanged
we do not need an exciting fall for the user interface
the user interfaces in the story board already
we just need
a dot h dot m father we can hook up to it so that's the first one
the classes created but there is no connection yet will do that in a moment
before i get them up
i'll just go back to my file menu
and create two more
new file
view control a subclass of kirker touch
now this one is not a table view controller
for justice playing the photo and i'll call this display view controllers
it's a regular you argue controller
den both checkboxes on checked
click next
click create to add to the project
and one more
new file
view controller subclass
final view control we have a nice storyboard
and this is showing information
chocolate info view controller
subclass of you are a few controller not you like it will be controller
and both checkboxes on checks click next and create
so in my project alligator we have six new false history dot page history dot
ames'
and these will correspond
to our three scenes that we need to write custom code for
we don't need to write any custom code for the navigation controller it's just
going to work as it normally works
here's the very very very important step
right now
there is nothing
connecting
these parts of the story board to all those close files that we just wrote
we're gonna have to do that
to do that i'm going to open up my utilities panel
i'm going to make sure that i zoom in that full size so i can properly
interact with these for me it's only reliable hundred-percent
and looking first at the table view controller
i want to connect this to our
photos table view controller class files
how i do this
is by selecting the view controller icon down the dark where it says table view
controller
doing over into my inspectors and the one that i want to be as the identity
and specter
which right at the top says that as far as its concern right now it believes the
class for this user interface file is just generic
you aren't able to control the built in one and i a west
and i'm saying no i don't want the generic one i want
our you aren't able to control the one i just created
cyclic the dropdown
and it's actually smart enough to know that the only class in this project
that's worthwhile connecting to
is the one that inherits from you aren't able to control which is
photos table you control
so that's the first one connected
i'd jump across two
what will show the details of the photo the actual photo itself
click it
and making sure the with the icons selected i select view controlling so
that the whole thing has the blue outline
and in the identity inspector here saying no it's not getting art you argue
controller anymore
it should be hooked up to
the
every odd display view controller
we have a few more choices here because there's a few more classes
in our project and available to us that inherit from you argue controller
you want to be very careful at this stage
that you're hurting
the right part of your story board up
to the right class
so checked them and double-checked them
and then the final view controller
which will show information about the class so
selecting somewhere in their view controller so that our i can show up
selecting view controller items we see the blue outline
the says it's generic you argue controller
no in needs to be the info do you control whether we just made there we go
hands that is the connections
between uh... storyboard
and the custom classes that we have
now moving on
a moment ago we created a custom class of photo class
question is
which of these view control his need to know about that for the class
all of them
this one's going to display them in a table view this one's going to show an
image with data from that objects and this one's gonna show information about
that object
so very quickly what i'm going to do is john over
to the header file from my photos table view controller
an ad
an import statement
we import photo dot h
i'm gonna copy that line
and just paste it at the top of our display view controller
and on involve you controller
will not only that but what we're thinking about
what classes need to know about what other classes
we're going to show a gray from the photos table view controller
display of your control
i'm organising away from the display view controller to the in for a few
control
and if we're going to pass information between them that means the table view
needs to know about the display view controller
and the display view controlling needs to know about the improving controller
for us what that means is i'll go to my table view controller header file
and also had an import statement
for the displayed you control
so it knows about the one it's going to segue to them
similarly
i'll jump to the display view control a header file and tell it
to import the header
for the in for a few controller
okay well what else
organza and double loading some data
into this table view controller so we need
some way to hold that one i'm going to do is actually just jump across
just to the implementation filed the photos table view controller dot them
farm and after the implementation statement
i'm just going to create and an s
musical array changeable
who arranged second hold some information about our photos they can
hold a bunch of photo objects
i don't need to make this a property because it doesn't need to be accessible
from outside this particular view controller
we're not going to pass the array around
we might pass individual objects around
i'm going to load that in a minute
and looking at the story board again just to get some perspective
the display b controller and in for a few controller don't need an array
but they both do need a place to put it in individual photo object they need a
place to store one as being passed around
so in the header file for the display view controller
i'm going to add a property
and this would just be a place to hold and given name too
a reference to a photo object will call what kind of photo
i'll copy that because i'm going to use that again in just a moment
the one in the display view control header file i'll jump to the displayed
you control implementation file an inside implementation
make sure to synthesize it properly
then jump finally to our in for a few controller had to file
had the same property because we need a place to store current photo in this
view controllers while
an ad it's corresponding synthesize statement
and eyes were preparing everything here
going to take a look at the story boarding realize
okay if we're going to be working with as you like
image view
to display our photo
we're prolly gonna need to access this income which i'm gonna make this an
outlets
give myself a bit more room and open up to the assistant editor
so with you why image you selected need anyone to be
careful you're selecting the right thing you can use the jumbo are here to make
sure that you got the image of you selected
this system should be showing you the corresponding header file which is
correct for me it's the display view controller
so i'm going to control drag
inside the interface declaration and create an outlet
that i'll call current image
doublecheck to make sure it seems to be creating the right object type of you i
a m interview bass looks correct
and and a similar sense what i'm going to do is just
click on the final scene so we jump to the in for a few controller header file
because i want to hook up the label as a mallet as well
so making sure the label is properly selected
control drag into the interface
amma call this a details of the label
we haven't done anything with the label or the image yet but we're going to send
both of those values in the next step