1 00:00:00,400 --> 00:00:03,430 In the Apple platform we have a lot of different frameworks. 2 00:00:03,510 --> 00:00:05,280 So someone from that we have. 3 00:00:05,280 --> 00:00:12,840 You've heard of is the UI kit and we have foundation and so many others but now we have been talking 4 00:00:12,840 --> 00:00:17,400 about safety y as another framework in the Apple platform. 5 00:00:17,400 --> 00:00:23,180 Now what is a framework framework is just a bunch of libraries that allow users. 6 00:00:23,280 --> 00:00:27,990 In this case developers to leverage the underlying operating system. 7 00:00:27,990 --> 00:00:30,480 In this case of the Apple platform that's what it is. 8 00:00:30,540 --> 00:00:37,770 You like heat has all of these libraries classes and so forth that let developers invoke or leverage 9 00:00:37,980 --> 00:00:44,620 the user interface and then many add properties they need to create applications on that platform. 10 00:00:44,640 --> 00:00:49,890 In this case Apple platform foundation framework is another framework that its use in conjunction with 11 00:00:49,890 --> 00:00:51,390 UI kit and so forth. 12 00:00:51,390 --> 00:00:58,470 That gives us more capability more classes more libraries perhaps to deal with more low level and primitive 13 00:00:58,560 --> 00:01:01,250 properties and classes and so forth. 14 00:01:01,290 --> 00:01:07,530 Now Swifty y as you know by now allows us to create user interface much much easier. 15 00:01:07,630 --> 00:01:15,060 Now deal here is that Swifty y as its own framework needs a way in which it can communicate with the 16 00:01:15,060 --> 00:01:21,840 UI kit meaning because swift UI is quote unquote I would say is limited in so many ways. 17 00:01:21,840 --> 00:01:29,310 At this point at least for now there are things that we may want to place inside of a swifty Y from 18 00:01:29,310 --> 00:01:30,270 UI kit. 19 00:01:30,360 --> 00:01:37,280 So the idea here is that we can borrow certain views or certain classes or certain things that you could 20 00:01:37,290 --> 00:01:39,200 provide into our safety y. 21 00:01:39,360 --> 00:01:41,520 In this process here at this point here. 22 00:01:41,520 --> 00:01:48,480 So the process of taking placing views from UI kit into Swifty Y is what we call its what we call UI 23 00:01:48,480 --> 00:01:48,940 view. 24 00:01:48,970 --> 00:01:50,910 Re presentable protocol. 25 00:01:50,920 --> 00:01:57,510 So in order for this transaction to happen we need to embed a protocol called UI view represent all. 26 00:01:57,570 --> 00:02:03,200 Now the next question you may ask is what is indeed a protocol because you may have heard of protocols. 27 00:02:03,210 --> 00:02:07,280 Maybe I have mentioned in passing and you may be confused. 28 00:02:07,290 --> 00:02:09,470 Protocol What is that. 29 00:02:09,510 --> 00:02:10,900 Let's talk about that. 30 00:02:10,950 --> 00:02:20,010 Well a protocol is some sort of a blueprint that defines methods properties and other requirements that 31 00:02:20,010 --> 00:02:23,760 suit a particular task or piece of functionality. 32 00:02:23,760 --> 00:02:28,830 What that means is when we look at inheritance in object oriented programming we may have for instance 33 00:02:29,160 --> 00:02:30,820 a person class. 34 00:02:30,990 --> 00:02:36,510 And then at the bottom we have a developer while a developer is a person which means will then inherit 35 00:02:36,510 --> 00:02:37,380 from person. 36 00:02:37,410 --> 00:02:43,890 In this case here you can see there is a hierarchy of the top superclass and at the bottom subclasses 37 00:02:44,040 --> 00:02:46,780 right the children glasses. 38 00:02:46,830 --> 00:02:48,750 So a developer inherits from person. 39 00:02:48,750 --> 00:02:55,740 However for more flexibility we could create some sort of a different class a blueprint of methods properties 40 00:02:55,740 --> 00:03:02,460 and other requirements that can be adopted by a class or a struct or a num whatever structure that we 41 00:03:02,460 --> 00:03:03,450 are creating. 42 00:03:03,690 --> 00:03:09,660 So that those classes it's actually required to implement those properties methods and so forth. 43 00:03:09,660 --> 00:03:14,490 In this case here a developer would say well in order for you to be a developer because you understand 44 00:03:14,490 --> 00:03:16,940 you inherit from person that's that's established. 45 00:03:17,100 --> 00:03:23,880 But in order for you to be developer you also have to be instructing all meaning that you have to conform 46 00:03:23,880 --> 00:03:29,370 to the instructional protocol which also means that in order for you to be a developer you have to be 47 00:03:29,370 --> 00:03:30,870 indestructible. 48 00:03:30,870 --> 00:03:32,730 Otherwise that's not going to work. 49 00:03:32,730 --> 00:03:41,100 What that means in code is that whenever we creating a developer in this case and we come farm to protocol 50 00:03:41,310 --> 00:03:49,980 that just means then that I have to satisfy a certain requirement or certain requirements that our protocol 51 00:03:49,980 --> 00:03:56,110 may have for us because remember the protocol is just a blueprint of what needs to be done. 52 00:03:56,110 --> 00:04:03,700 It's like a contract that says OK if you confirm to me if you want to be me then you have to do these 53 00:04:03,700 --> 00:04:04,250 things. 54 00:04:04,270 --> 00:04:09,120 A developer in order for him or she to become a developer it has been structural indestructible as a 55 00:04:09,120 --> 00:04:16,450 protocol as a blueprint will have properties methods and so forth that anybody who conforms to it must 56 00:04:16,540 --> 00:04:19,620 abide by almost like a law. 57 00:04:19,770 --> 00:04:21,940 That's what a protocol is. 58 00:04:21,940 --> 00:04:28,750 So this now gives us a lot of flexibility because a developer could inherited from one person of course 59 00:04:28,960 --> 00:04:36,910 but a developer can also implement or conform to many different protocols. 60 00:04:36,910 --> 00:04:37,590 That is the beauty. 61 00:04:37,600 --> 00:04:43,520 So it gives us this flexibility and notice that the protocol here has nothing to do with person or developer. 62 00:04:43,530 --> 00:04:44,420 In many ways. 63 00:04:44,500 --> 00:04:44,890 Right. 64 00:04:44,890 --> 00:04:51,410 A developer in this case could go and confirm to many other protocol likable or whatever else. 65 00:04:51,410 --> 00:04:54,790 And the protocol that may make sense for a developer. 66 00:04:54,880 --> 00:04:59,470 So how does this all make sense to what we are trying to do with the UI viewer were presentable. 67 00:04:59,470 --> 00:05:05,410 Well this concept is the same if we look here do you why if you were presentable protocol allows us 68 00:05:05,410 --> 00:05:14,110 to put together for instance we can have a class map view and we want this map view to confirm to the 69 00:05:14,290 --> 00:05:16,320 UI you represent of a protocol. 70 00:05:16,330 --> 00:05:21,520 So in this case here do you I view represent a rule which has a protocol will have for instance to make 71 00:05:21,520 --> 00:05:25,810 you eye view method and update you are viewed method in many others method. 72 00:05:25,840 --> 00:05:27,510 And it could also have properties. 73 00:05:27,700 --> 00:05:28,220 Right. 74 00:05:28,240 --> 00:05:34,240 So now our map view here because we want to take this map view and put in so if you why we have to confirm 75 00:05:34,240 --> 00:05:39,240 to that UI view presentable because then we have to go confirm to. 76 00:05:39,280 --> 00:05:43,750 Do you have your presentable because we want to be able to take advantage of the make you eye view and 77 00:05:43,750 --> 00:05:44,440 update your eye view. 78 00:05:44,440 --> 00:05:46,600 In fact we have no choice. 79 00:05:46,600 --> 00:05:47,860 The moment we confirmed we. 80 00:05:47,870 --> 00:05:51,780 That means we are signing the contract so that we can do what is split. 81 00:05:51,790 --> 00:05:55,900 What are we supposed to do which in this case has to be make you eye view and update to eye view. 82 00:05:56,290 --> 00:06:02,860 What that means then is that the map view would have those methods must have those methods or must implement 83 00:06:03,130 --> 00:06:10,410 those methods to actually have or add code inside of to make you eye view and empty white view. 84 00:06:10,480 --> 00:06:15,610 And that's where we are able then to put the code that will then create the view and to make you eye 85 00:06:15,610 --> 00:06:17,980 view and update anything inside of you. 86 00:06:18,160 --> 00:06:22,870 So that then we able to embed that into a swift UI. 87 00:06:22,900 --> 00:06:31,150 So any view that we may not have directly within Swifty y we can actually get all of those views from 88 00:06:31,360 --> 00:06:34,950 the from the UI kit because it has everything. 89 00:06:34,960 --> 00:06:35,240 Right. 90 00:06:35,590 --> 00:06:39,790 And for that to happen we have to take that class we created with struct. 91 00:06:39,970 --> 00:06:46,030 And it has to confirm to the UI viewer presentable because that will allow us to represent what's when 92 00:06:46,030 --> 00:06:49,130 we like it into swift UI. 93 00:06:49,150 --> 00:06:54,880 So whenever you hear about me saying about a protocol conform to a protocol and so forth that's what 94 00:06:54,880 --> 00:06:55,210 it means. 95 00:06:55,210 --> 00:07:01,540 It just means we are taking from a defined blueprint of methods property and other requirements that 96 00:07:01,540 --> 00:07:04,440 suit a certain task or piece of functionality. 97 00:07:04,660 --> 00:07:04,870 Right. 98 00:07:04,870 --> 00:07:06,510 We're putting it all there laid out. 99 00:07:06,520 --> 00:07:14,100 No implementation so that anybody who wants to use or confirmed to us or be like us they have to for 100 00:07:14,100 --> 00:07:14,920 him to ask me. 101 00:07:14,920 --> 00:07:19,380 Meaning that they have to implement those methods that we are making available for them. 102 00:07:19,390 --> 00:07:19,660 All right. 103 00:07:19,660 --> 00:07:20,080 So that's it. 104 00:07:20,080 --> 00:07:25,210 So what are we gonna do now we're going to create a map view struct which will confirm to you viewer 105 00:07:25,300 --> 00:07:31,690 presentable so that we can then do that then we can create the view the actual map and then update that 106 00:07:31,690 --> 00:07:35,450 view instead of the Swift UI view. 107 00:07:35,590 --> 00:07:36,460 Let's go ahead and do that.