So will come again this lesson is actually an exercise on what you have to do is you have to make and
an OP that has an image of you slider.
And as you slide through with this slide there the images in the image of you should change of course
you try to make everything as dynamic as you can so you put your images in an array.
You set the minimum and maximum of your slider with the size of the array and you navigate the images
in the image of you depending on where you are in the slider.
So I have provided you some images.
These are those images.
They are not named properly or just this is intentional.
I just want you to see how we could use the names that we just find on the Internet or the files that
we read from some sort of a network or back and so add them to your project and get us started on the
good luck.
And at this point you might pause the video for a few minutes or give it a shot on your own and then
if you want it come back to my solution.
So let's get started.
Here is what I'm going to do.
I'm going to go to school when I close this project and then I start hey I'm going to close this project
does it.
I don't know why there's so many of them open.
I'm going to go ahead and say you manage a slide there slider.
That is my app and in my image just slide there with I'm going to do is I'm going to go ahead in here
on out all of these files in some when I copied the items on I usually like to place them all inside
there on our folders so a new group from selection.
I'm going to call it images.
So we got that part taken care of.
The next thing is I'm going to go to a storyboard and I'm going to add a slider this one for instance
and or other problem with my Magic Mouse sometimes it doesn't work properly.
So let's I add an image of you here now.
So I'm going to put it there.
And the only things I want to change is in the image view I want to say are icepack filled the same
thing that I've done before.
So this goes to the assistant editor load up are that age.
I'm going to make art two outlets and one action.
So this is my slide.
This is my image of you.
And this is going to be the action for the slide action that's about that.
I have two properties and one action.
So in that age that's where they got this go to that.
And now I'm going to clean everything.
I don't need
but the first thing I need to do is I need to populate array with the name of all of these images.
So here is what I'm going to do I'm going to stay up there and this and it's array let's call it images
array in a new function call with that populates array.
I'm going to say image array is a..
Array lock in its heavy object.
And here's a little trick I want to show you.
That is from Mac operating system.
If I go in here and I select all of these I had command C to copy.
If I come by here and had command be it I truly copy paste the names of all of those files which really
helps me whenever I'm doing testing or for whatever reason.
I have a group of files that are static and I don't I can't you know copy their names of one at a time
so I just go here to my finder copy these come and see come by here had come on the I pace all of the
names.
So now I have to do is I have to add the estranging marks for them.
So dot dot dot dot.
It's a little bit of a you know process.
It's a lot better than having to type everything on our own.
So.
So that's.
And finally I have one extra one so and this array is now populated with all of them.
It doesn't matter whether you use this trick or if you actually typed them on or if you want to rename
the files just find a way to populate all of the images inside an image array and then actually take
this function with at the very bottom because I don't really need after this.
What they do need to do is I need to call it in my view the Lord say my lord I'm going to say South
Park played every song in this function is now being called right at the very beginning.
And before this one if you remember I heard the commands were then click on the name of the function
and I had failed.
And now the next thing I want to do is this as the slide slides I have to find its value and I have
to assign one of my images to it.
But before that I need to set the minimum and maximum of my slider.
So they represent the same minimum maximum of my array.
So I'm going to say my a slider darts minimum value is going to be zero that's for sure.
And my a slider dart maximum value it's going to be images array dot counts not.
Think about that for a second.
If my images is array that count is let's say 15 I set the maximum value to 15.
It simply means I will include 15 itself which is not really a good thing because I don't have an index
such as 15 in my array.
I have one Beloit.
I have 14 of them because the indexes are between zero to 14 that they make up for 15 objects.
Right.
So because of that I'm going to actually say the maximum value is images are a count minus one.
So that's taking off.
Now the next thing is I'm a sliding I have to get the value of my of my a slider so I'm going to say
are integer my index is going to be my slider Dart's value.
One of the problems I'm facing here is that the value is actually a flawed number that it has decimal
points.
And if I'm going to try to convert that into an integer I could simply go ahead in here and say get
the integer part of it.
This is however not the best approach simply because when I am converting it to integer I'm just dismissing
the decimal part.
So let me quickly explain that it means something such as 2.6 when we can see that two and two point
ninety nine.
Also be considered two which is not really a good option.
I mean ideally we would like to see something such as 2.6 to be three and two point nine.
Also it would be three but then we would want to see two point four nine will be true simply because
that's how we round values.
And because of that instead of doing our casting into integer I'm going to say let's do this let's say
around and I'm going use around F for float and I'm going to say round that this is ideal for me.
So then your round the value it takes it from the middle two point five and above they become twenty
two point forty nine and below they become two essentially what I have you here.
I should mention two other are essentially methods for mathematical calculations.
One of them is c and c f essentially which means push everything to the ceiling in C two point six becomes
three two point nine nine becomes three and two point 0 0 0 5 again becomes three because between two
to three it goes to the ceiling of that.
And there is another one called floor.
And as you can imagine Flora would push two point six to two point nine nine to two to a point 0 0 0
5 again to two.
So that two of them around floor unsealed and depending on the situation you might want to use one of
them.
The one I want to use in here is actually round and I would use a round F because my value is in front.
So now I have the value of my slider in a flop in an integer format.
So the next thing I have to do is I have to say next thing is actually very simple right.
I have to say my image of you that image is going to be a I emerge with an email name and a name for
it is going to be images array object that index.
Let's use a subscript this time.
You know I always use the object that index lets just use a different format.
So this time I'm going to say images array open brackets in front of it and say my index and that's
about that.
Let's see if it works.
So once it launches on my simulator I should be able to use the slide there and go between different
images.
Perfect.
All right.
So that's about that for this assignment.
It was a rather simple one.
This method you can see right now with remember that populates the array.
The other two matters the ones that are actually kind of important are these set them anywhere a maximum
of my slider.
And then they get the rounded version of the value of my smy there and they plug that into my images
to get the correct image name and convert the image name into a major issue.
In turn will be plugged into the age of my image of you and that's about that.
With that in mind let's move on.