1 00:00:01,110 --> 00:00:07,390 So will come again this lesson is actually an exercise on what you have to do is you have to make and 2 00:00:07,510 --> 00:00:10,840 an OP that has an image of you slider. 3 00:00:11,120 --> 00:00:17,210 And as you slide through with this slide there the images in the image of you should change of course 4 00:00:17,240 --> 00:00:22,540 you try to make everything as dynamic as you can so you put your images in an array. 5 00:00:22,670 --> 00:00:29,120 You set the minimum and maximum of your slider with the size of the array and you navigate the images 6 00:00:29,120 --> 00:00:32,810 in the image of you depending on where you are in the slider. 7 00:00:33,020 --> 00:00:35,420 So I have provided you some images. 8 00:00:35,420 --> 00:00:36,840 These are those images. 9 00:00:36,890 --> 00:00:40,160 They are not named properly or just this is intentional. 10 00:00:40,160 --> 00:00:46,250 I just want you to see how we could use the names that we just find on the Internet or the files that 11 00:00:46,250 --> 00:00:52,740 we read from some sort of a network or back and so add them to your project and get us started on the 12 00:00:52,740 --> 00:00:53,510 good luck. 13 00:00:53,540 --> 00:00:59,120 And at this point you might pause the video for a few minutes or give it a shot on your own and then 14 00:00:59,120 --> 00:01:01,940 if you want it come back to my solution. 15 00:01:04,300 --> 00:01:05,310 So let's get started. 16 00:01:05,320 --> 00:01:06,630 Here is what I'm going to do. 17 00:01:06,630 --> 00:01:12,140 I'm going to go to school when I close this project and then I start hey I'm going to close this project 18 00:01:12,140 --> 00:01:12,580 does it. 19 00:01:12,580 --> 00:01:14,910 I don't know why there's so many of them open. 20 00:01:14,950 --> 00:01:20,980 I'm going to go ahead and say you manage a slide there slider. 21 00:01:21,340 --> 00:01:28,940 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 22 00:01:28,950 --> 00:01:39,860 on out all of these files in some when I copied the items on I usually like to place them all inside 23 00:01:39,860 --> 00:01:43,690 there on our folders so a new group from selection. 24 00:01:43,890 --> 00:01:45,990 I'm going to call it images. 25 00:01:46,290 --> 00:01:48,380 So we got that part taken care of. 26 00:01:48,660 --> 00:01:57,260 The next thing is I'm going to go to a storyboard and I'm going to add a slider this one for instance 27 00:01:57,900 --> 00:02:04,080 and or other problem with my Magic Mouse sometimes it doesn't work properly. 28 00:02:04,080 --> 00:02:09,160 So let's I add an image of you here now. 29 00:02:11,110 --> 00:02:13,220 So I'm going to put it there. 30 00:02:13,610 --> 00:02:21,700 And the only things I want to change is in the image view I want to say are icepack filled the same 31 00:02:21,700 --> 00:02:23,200 thing that I've done before. 32 00:02:23,410 --> 00:02:27,650 So this goes to the assistant editor load up are that age. 33 00:02:28,000 --> 00:02:32,140 I'm going to make art two outlets and one action. 34 00:02:32,230 --> 00:02:35,980 So this is my slide. 35 00:02:36,520 --> 00:02:41,060 This is my image of you. 36 00:02:41,210 --> 00:02:49,270 And this is going to be the action for the slide action that's about that. 37 00:02:49,270 --> 00:02:52,920 I have two properties and one action. 38 00:02:53,030 --> 00:02:57,540 So in that age that's where they got this go to that. 39 00:02:57,590 --> 00:02:59,800 And now I'm going to clean everything. 40 00:02:59,800 --> 00:03:00,550 I don't need 41 00:03:05,140 --> 00:03:11,930 but the first thing I need to do is I need to populate array with the name of all of these images. 42 00:03:11,940 --> 00:03:21,870 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 43 00:03:21,960 --> 00:03:30,410 array in a new function call with that populates array. 44 00:03:30,720 --> 00:03:34,090 I'm going to say image array is a.. 45 00:03:34,110 --> 00:03:38,470 Array lock in its heavy object. 46 00:03:38,640 --> 00:03:40,530 And here's a little trick I want to show you. 47 00:03:40,530 --> 00:03:43,170 That is from Mac operating system. 48 00:03:43,170 --> 00:03:48,990 If I go in here and I select all of these I had command C to copy. 49 00:03:49,200 --> 00:03:56,310 If I come by here and had command be it I truly copy paste the names of all of those files which really 50 00:03:56,310 --> 00:04:00,250 helps me whenever I'm doing testing or for whatever reason. 51 00:04:00,390 --> 00:04:06,960 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 52 00:04:07,200 --> 00:04:13,740 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 53 00:04:13,740 --> 00:04:14,430 names. 54 00:04:14,430 --> 00:04:18,180 So now I have to do is I have to add the estranging marks for them. 55 00:04:18,180 --> 00:04:22,280 So dot dot dot dot. 56 00:04:22,380 --> 00:04:24,610 It's a little bit of a you know process. 57 00:04:24,620 --> 00:04:29,410 It's a lot better than having to type everything on our own. 58 00:04:29,410 --> 00:04:30,250 So. 59 00:04:30,750 --> 00:04:32,120 So that's. 60 00:04:32,400 --> 00:04:40,830 And finally I have one extra one so and this array is now populated with all of them. 61 00:04:41,010 --> 00:04:45,840 It doesn't matter whether you use this trick or if you actually typed them on or if you want to rename 62 00:04:45,840 --> 00:04:53,850 the files just find a way to populate all of the images inside an image array and then actually take 63 00:04:53,850 --> 00:04:59,820 this function with at the very bottom because I don't really need after this. 64 00:04:59,970 --> 00:05:06,620 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 65 00:05:06,710 --> 00:05:12,650 Park played every song in this function is now being called right at the very beginning. 66 00:05:12,930 --> 00:05:18,120 And before this one if you remember I heard the commands were then click on the name of the function 67 00:05:18,150 --> 00:05:19,360 and I had failed. 68 00:05:19,680 --> 00:05:27,780 And now the next thing I want to do is this as the slide slides I have to find its value and I have 69 00:05:27,780 --> 00:05:30,800 to assign one of my images to it. 70 00:05:30,810 --> 00:05:35,600 But before that I need to set the minimum and maximum of my slider. 71 00:05:35,640 --> 00:05:39,630 So they represent the same minimum maximum of my array. 72 00:05:39,840 --> 00:05:50,780 So I'm going to say my a slider darts minimum value is going to be zero that's for sure. 73 00:05:50,850 --> 00:05:59,470 And my a slider dart maximum value it's going to be images array dot counts not. 74 00:05:59,550 --> 00:06:01,510 Think about that for a second. 75 00:06:01,890 --> 00:06:10,880 If my images is array that count is let's say 15 I set the maximum value to 15. 76 00:06:10,890 --> 00:06:19,260 It simply means I will include 15 itself which is not really a good thing because I don't have an index 77 00:06:19,320 --> 00:06:21,530 such as 15 in my array. 78 00:06:21,600 --> 00:06:23,170 I have one Beloit. 79 00:06:23,190 --> 00:06:32,820 I have 14 of them because the indexes are between zero to 14 that they make up for 15 objects. 80 00:06:32,820 --> 00:06:33,380 Right. 81 00:06:33,510 --> 00:06:39,880 So because of that I'm going to actually say the maximum value is images are a count minus one. 82 00:06:40,200 --> 00:06:43,060 So that's taking off. 83 00:06:43,150 --> 00:06:50,400 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 84 00:06:51,130 --> 00:07:02,050 are integer my index is going to be my slider Dart's value. 85 00:07:02,310 --> 00:07:08,540 One of the problems I'm facing here is that the value is actually a flawed number that it has decimal 86 00:07:08,550 --> 00:07:09,280 points. 87 00:07:09,400 --> 00:07:15,480 And if I'm going to try to convert that into an integer I could simply go ahead in here and say get 88 00:07:15,480 --> 00:07:17,400 the integer part of it. 89 00:07:17,400 --> 00:07:25,320 This is however not the best approach simply because when I am converting it to integer I'm just dismissing 90 00:07:25,320 --> 00:07:26,660 the decimal part. 91 00:07:26,700 --> 00:07:35,760 So let me quickly explain that it means something such as 2.6 when we can see that two and two point 92 00:07:35,760 --> 00:07:36,830 ninety nine. 93 00:07:36,920 --> 00:07:40,620 Also be considered two which is not really a good option. 94 00:07:40,620 --> 00:07:48,450 I mean ideally we would like to see something such as 2.6 to be three and two point nine. 95 00:07:48,460 --> 00:07:54,690 Also it would be three but then we would want to see two point four nine will be true simply because 96 00:07:55,020 --> 00:07:57,040 that's how we round values. 97 00:07:57,180 --> 00:08:04,170 And because of that instead of doing our casting into integer I'm going to say let's do this let's say 98 00:08:04,170 --> 00:08:11,580 around and I'm going use around F for float and I'm going to say round that this is ideal for me. 99 00:08:11,580 --> 00:08:17,610 So then your round the value it takes it from the middle two point five and above they become twenty 100 00:08:17,910 --> 00:08:23,800 two point forty nine and below they become two essentially what I have you here. 101 00:08:23,850 --> 00:08:29,380 I should mention two other are essentially methods for mathematical calculations. 102 00:08:29,580 --> 00:08:38,730 One of them is c and c f essentially which means push everything to the ceiling in C two point six becomes 103 00:08:38,730 --> 00:08:46,740 three two point nine nine becomes three and two point 0 0 0 5 again becomes three because between two 104 00:08:46,740 --> 00:08:49,100 to three it goes to the ceiling of that. 105 00:08:49,380 --> 00:08:51,280 And there is another one called floor. 106 00:08:51,300 --> 00:08:57,990 And as you can imagine Flora would push two point six to two point nine nine to two to a point 0 0 0 107 00:08:57,990 --> 00:08:59,530 5 again to two. 108 00:08:59,700 --> 00:09:07,920 So that two of them around floor unsealed and depending on the situation you might want to use one of 109 00:09:07,920 --> 00:09:08,130 them. 110 00:09:08,130 --> 00:09:14,740 The one I want to use in here is actually round and I would use a round F because my value is in front. 111 00:09:14,970 --> 00:09:22,710 So now I have the value of my slider in a flop in an integer format. 112 00:09:22,710 --> 00:09:27,740 So the next thing I have to do is I have to say next thing is actually very simple right. 113 00:09:27,730 --> 00:09:36,690 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 114 00:09:36,690 --> 00:09:40,870 it is going to be images array object that index. 115 00:09:41,020 --> 00:09:42,830 Let's use a subscript this time. 116 00:09:42,840 --> 00:09:47,100 You know I always use the object that index lets just use a different format. 117 00:09:47,160 --> 00:09:56,590 So this time I'm going to say images array open brackets in front of it and say my index and that's 118 00:09:56,590 --> 00:09:58,090 about that. 119 00:09:58,090 --> 00:10:00,510 Let's see if it works. 120 00:10:00,550 --> 00:10:09,370 So once it launches on my simulator I should be able to use the slide there and go between different 121 00:10:09,370 --> 00:10:10,200 images. 122 00:10:11,430 --> 00:10:15,120 Perfect. 123 00:10:15,120 --> 00:10:15,630 All right. 124 00:10:15,640 --> 00:10:18,520 So that's about that for this assignment. 125 00:10:18,520 --> 00:10:21,320 It was a rather simple one. 126 00:10:21,610 --> 00:10:25,850 This method you can see right now with remember that populates the array. 127 00:10:26,050 --> 00:10:32,320 The other two matters the ones that are actually kind of important are these set them anywhere a maximum 128 00:10:32,320 --> 00:10:33,400 of my slider. 129 00:10:33,430 --> 00:10:40,360 And then they get the rounded version of the value of my smy there and they plug that into my images 130 00:10:40,680 --> 00:10:46,470 to get the correct image name and convert the image name into a major issue. 131 00:10:46,510 --> 00:10:53,170 In turn will be plugged into the age of my image of you and that's about that. 132 00:10:53,170 --> 00:10:55,180 With that in mind let's move on.