{"id":303060,"date":"2020-05-05T15:00:37","date_gmt":"2020-05-05T15:00:37","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=303060"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=303060","title":{"rendered":"\u0410\u0434\u0430\u043f\u0442\u0438\u0440\u0443\u0435\u043c \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0435 \u0431\u0438\u0437\u043d\u0435\u0441-\u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043f\u043e\u0434 SwiftUI. \u0427\u0430\u0441\u0442\u044c 4. \u041d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u044f \u0438 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f"},"content":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/500492\/\">\u0414\u043e\u0431\u0440\u043e\u0433\u043e \u0432\u0441\u0435\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0441\u0443\u0442\u043e\u043a! \u0421 \u0432\u0430\u043c\u0438 \u044f, \u0410\u043d\u043d\u0430 \u0416\u0430\u0440\u043a\u043e\u0432\u0430, \u0432\u0435\u0434\u0443\u0449\u0438\u0439 \u043c\u043e\u0431\u0438\u043b\u044c\u043d\u044b\u0439 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438 <a href=\"https:\/\/usetech.ru\/\" rel=\"nofollow\">\u00abUsetech\u00bb <\/a><br \/>  \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043e\u0431 \u0435\u0449\u0435 \u043e\u0434\u043d\u043e\u043c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u043c \u043c\u043e\u043c\u0435\u043d\u0442\u0435 \u0432 SwiftUI, \u043e \u043d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u0438. <br \/>  \u0415\u0441\u043b\u0438 \u0432\u044b \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u043b\u0438 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0435 \u0441\u0442\u0430\u0442\u044c\u0438 \u0446\u0438\u043a\u043b\u0430, \u0442\u043e \u043c\u043e\u0436\u0435\u0442\u0435 \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u0441 \u043d\u0438\u043c\u0438 \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435:<br \/>  <a href=\"https:\/\/habr.com\/ru\/post\/500194\/\">\u0447\u0430\u0441\u0442\u044c 1<\/a><br \/>  <a href=\"https:\/\/habr.com\/ru\/post\/500386\/\">\u0447\u0430\u0441\u0442\u044c 2<\/a><br \/>  <a href=\"https:\/\/habr.com\/ru\/post\/500470\/\">\u0447\u0430\u0441\u0442\u044c 3<\/a><\/p>\n<p>  \u0421 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435\u043c \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0432\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u0438 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u043e\u043c \u043a \u0434\u0435\u043a\u043b\u0430\u0440\u0430\u0442\u0438\u0432\u043d\u043e\u043c\u0443 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u0443 \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u043e\u0441\u044c \u0438 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u0435\u0439 \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 SwiftUI. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 UIViewContoller \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u043e\u0442\u0440\u0438\u0446\u0430\u0435\u0442\u0441\u044f, UINavigationController \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f. \u041d\u0430 \u0441\u043c\u0435\u043d\u0443 \u0435\u043c\u0443 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 NavigationView.  <\/p>\n<pre><code class=\"swift\">@available(iOS 13.0, OSX 10.15, tvOS 13.0, *) @available(watchOS, unavailable) public struct NavigationView&lt;Content&gt; : View where Content : View {      public init(@ViewBuilder content: () -&gt; Content)      \/\/.... } <\/code><\/pre>\n<p>   \u041f\u043e \u0441\u0443\u0442\u0438 \u043e\u0431\u0435\u0440\u0442\u043a\u0430 \u043d\u0430\u0434 UINavigationController \u0438 \u0435\u0433\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u043e\u043c. <br \/>  <a name=\"habracut\"><\/a><br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/y2\/7c\/ee\/y27ceeieqhsosve9hkdmhry_q-y.png\" width=\"50%\"><br \/>  \u041e\u0441\u043d\u043e\u0432\u043d\u044b\u043c \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u043e\u043c \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f NavigationLink (\u0430\u043d\u0430\u043b\u043e\u0433 segue), \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0437\u0430\u0434\u0430\u0435\u0442\u0441\u044f \u0441\u0440\u0430\u0437\u0443 \u0436\u0435 \u0432 \u043a\u043e\u0434\u0435 body View.   <\/p>\n<pre><code class=\"swift\">public struct NavigationLink&lt;Label, Destination&gt; : View where Label : View,                                                                                             Destination : View { .     public init(destination: Destination, @ViewBuilder label: () -&gt; Label)      public init(destination: Destination, isActive: Binding&lt;Bool&gt;,                     @ViewBuilder label: () -&gt; Label)      public init&lt;V&gt;(destination: Destination, tag: V, selection: Binding&lt;V?&gt;,                           @ViewBuilder label: () -&gt; Label) where V : Hashable \/\/.... } <\/code><\/pre>\n<p>  \u041f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 NavigationLink \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 View, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0435\u0440\u0435\u0445\u043e\u0434, \u0430 \u0442\u0430\u043a\u0436\u0435 View, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 NavigationLink \u043e\u0431\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u0442, \u0442.\u0435 \u043f\u0440\u0438 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0438 \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c NavigationLink \u0430\u043a\u0442\u0438\u0432\u0438\u0437\u0438\u0440\u0443\u0435\u0442\u0441\u044f. \u0411\u043e\u043b\u044c\u0448\u0435 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0445 \u0441\u043f\u043e\u0441\u043e\u0431\u0430\u0445 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 NavigationLink \u0432 <a href=\"https:\/\/developer.apple.com\/documentation\/swiftui\/navigationlink\" rel=\"nofollow\">\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 Apple<\/a><\/p>\n<p>  \u041e\u0434\u043d\u0430\u043a\u043e \u0441\u0442\u043e\u0438\u0442 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c, \u0447\u0442\u043e \u0438\u0437-\u0437\u0430 \u0438\u043d\u043a\u0430\u043f\u0441\u0443\u043b\u044f\u0446\u0438\u0438 \u043f\u0440\u044f\u043c\u043e\u0433\u043e \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0441\u0442\u0435\u043a\u0443 View \u043d\u0435\u0442, \u043d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u043e \u0437\u0430\u0434\u0430\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u043f\u0435\u0440\u0435\u0434, \u0432\u043e\u0437\u0432\u0440\u0430\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u0435\u043d \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 1 \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u043d\u0430\u0437\u0430\u0434 \u0438 \u0442\u043e \u0447\u0435\u0440\u0435\u0437 \u0438\u043d\u043a\u0430\u043f\u0441\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043a\u043e\u0434 \u0434\u043b\u044f \u043a\u043d\u043e\u043f\u043a\u0438 \u00abBack\u00bb<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/hj\/ph\/br\/hjphbrs_ggmblirlejkozwj3wig.png\" width=\"50%\"><br \/>  \u0422\u0430\u043a\u0436\u0435 \u0432 SwiftUI \u043d\u0435\u0442 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u043e\u0439 \u043d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u0438. \u0415\u0441\u043b\u0438 \u043f\u0435\u0440\u0435\u0445\u043e\u0434 \u043f\u0440\u0438\u0432\u044f\u0437\u0430\u043d \u043d\u0435 \u043a \u0442\u0440\u0438\u0433\u0433\u0435\u0440\u043d\u043e\u043c\u0443-\u0441\u043e\u0431\u044b\u0442\u0438\u044e, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043d\u0430\u0436\u0430\u0442\u0438\u044e \u043d\u0430 \u043a\u043d\u043e\u043f\u043a\u0443, \u0430 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043a\u0430\u043a \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u043b\u043e\u0433\u0438\u043a\u0438, \u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0442\u0430\u043a \u044d\u0442\u043e \u043d\u0435 \u0441\u0434\u0435\u043b\u0430\u0442\u044c. \u041f\u0435\u0440\u0435\u0445\u043e\u0434 \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 View \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u0438\u0432\u044f\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043a \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0443 NavigationLink, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0437\u0430\u0434\u0430\u044e\u0442\u0441\u044f \u0434\u0435\u043a\u043b\u0430\u0440\u0430\u0442\u0438\u0432\u043d\u043e \u0441\u0440\u0430\u0437\u0443 \u0436\u0435 \u043f\u0440\u0438 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0438 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0435\u0433\u043e \u0438\u0445 View. \u0412\u0441\u0435.<br \/>  \u0415\u0441\u043b\u0438 \u043d\u0430\u0448 \u044d\u043a\u0440\u0430\u043d \u0434\u043e\u043b\u0436\u0435\u043d \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u0445\u043e\u0434 \u043d\u0430 \u043c\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u043d\u044b\u0445 \u044d\u043a\u0440\u0430\u043d\u043e\u0432, \u0442\u043e \u043a\u043e\u0434 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0433\u0440\u043e\u043c\u043e\u0437\u0434\u043a\u0438\u043c:  <\/p>\n<pre><code class=\"swift\">  NavigationView{             NavigationLink(destination: ProfileView(), isActive: self.$isProfile) {                 Text(&quot;Profile&quot;)             }             NavigationLink(destination: Settings(), isActive: self.$isSettings) {                            Text(&quot;Settings&quot;)                        }             NavigationLink(destination: Favorite(), isActive: self.$isFavorite) {                 Text(&quot;Favorite&quot;)             }             NavigationLink(destination: Login(), isActive: self.$isLogin) {                 Text(&quot;Login&quot;)             }             NavigationLink(destination: Search(), isActive: self.$isSearch) {                 Text(&quot;Search&quot;)             } } <\/code><\/pre>\n<p>  \u0423\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0441\u0441\u044b\u043b\u043a\u0430\u043c\u0438 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 \u0441\u043f\u043e\u0441\u043e\u0431\u0430\u043c\u0438:<br \/>   \u2014 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c\u044e NavigationLink \u0447\u0435\u0440\u0435\u0437 @Binding \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e  <\/p>\n<pre><code class=\"swift\"> NavigationLink(destination: ProfileView(), isActive: self.$isProfile) {                 Text(&quot;Profile&quot;)             } <\/code><\/pre>\n<p>   \u2014 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435\u043c \u0441\u0441\u044b\u043b\u043a\u0438 \u0447\u0435\u0440\u0435\u0437 \u0443\u0441\u043b\u043e\u0432\u0438\u0435 (\u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f)  <\/p>\n<pre><code class=\"swift\">       if self.isProfile {             NavigationLink(destination: ProfileView()) {                 Text(&quot;Profile&quot;)             } } <\/code><\/pre>\n<p>  \u041f\u0435\u0440\u0432\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u043d\u0430\u043c \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u043e \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044e \u0437\u0430 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435\u043c \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445. \u0415\u0441\u043b\u0438 \u0443 \u043d\u0430\u0441 \u043f\u043b\u0430\u043d\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u044f \u043d\u0430 \u0431\u043e\u043b\u0435\u0435, \u0447\u0435\u043c 1 \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u0432\u043f\u0435\u0440\u0435\u0434, \u0442\u043e \u044d\u0442\u043e \u0432\u0435\u0441\u044c\u043c\u0430 \u0442\u044f\u0436\u0435\u043b\u0430\u044f \u0437\u0430\u0434\u0430\u0447\u0430.<br \/>  \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u044d\u043a\u0440\u0430\u043d\u0430 \u0441\u043f\u0438\u0441\u043a\u0430 \u043e\u0434\u043d\u043e\u0442\u0438\u043f\u043d\u044b\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0432\u0441\u0435 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043a\u043e\u043c\u043f\u0430\u043a\u0442\u043d\u043e:  <\/p>\n<pre><code class=\"swift\"> NavigationView{         List(model.data) { item in             NavigationLink(destination: NewsItemView(item:item)) {             NewsItemRow(data: item)             }         } <\/code><\/pre>\n<p>  \u0421\u0430\u043c\u043e\u0439 \u0441\u0435\u0440\u044c\u0435\u0437\u043d\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043e\u0439 NavigationLink, \u043d\u0430 \u043c\u043e\u0439 \u0432\u0437\u0433\u043b\u044f\u0434, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u043e, \u0447\u0442\u043e \u0432\u0441\u0435 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0435 \u0432 \u0441\u0441\u044b\u043b\u043a\u0430\u0445 View \u043d\u0435 lazy. \u041e\u043d\u0438 \u0441\u043e\u0437\u0434\u0430\u044e\u0442\u0441\u044f \u043d\u0435 \u0432 \u043c\u043e\u043c\u0435\u043d\u0442 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u043d\u0438\u044f \u0441\u0441\u044b\u043b\u043a\u0438, \u0430 \u0432 \u043c\u043e\u043c\u0435\u043d\u0442 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f. \u0415\u0441\u043b\u0438 \u0443 \u043d\u0430\u0441 \u0441\u043f\u0438\u0441\u043e\u043a \u043d\u0430 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0438\u043b\u0438 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u044b \u043d\u0430 \u043c\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u043d\u044b\u0445 \u0442\u044f\u0436\u0435\u043b\u044b\u0445 \u043f\u043e \u043a\u043e\u043d\u0442\u0435\u043d\u0442\u0443 View, \u0442\u043e \u044d\u0442\u043e \u043d\u0435 \u043b\u0443\u0447\u0448\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 performance \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u0415\u0441\u043b\u0438 \u0436\u0435 \u0435\u0449\u0435 \u0443 \u043d\u0430\u0441 \u043a \u044d\u0442\u0438\u043c View \u043f\u0440\u0438\u0432\u044f\u0437\u0430\u043d\u044b ViewModel \u0441 \u043b\u043e\u0433\u0438\u043a\u043e\u0439, \u0432 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043d\u0435 \u0443\u0447\u0442\u0435\u043d \u0438\u043b\u0438 \u0443\u0447\u0442\u0435\u043d \u043d\u0435 \u0432\u0435\u0440\u043d\u043e life-cycle View, \u0442\u043e \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0441\u043e\u0432\u0441\u0435\u043c \u0442\u044f\u0436\u0435\u043b\u043e\u0439. <br \/>  \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u043d\u043e\u0432\u043e\u0441\u0442\u0435\u0439 \u0441 \u043e\u0434\u043d\u043e\u0442\u0438\u043f\u043d\u044b\u043c\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c\u0438. \u041c\u044b \u0435\u0449\u0435 \u043d\u0438 \u0440\u0430\u0437\u0443 \u043d\u0435 \u043f\u0435\u0440\u0435\u0448\u043b\u0438 \u043d\u0438 \u043d\u0430 \u043e\u0434\u0438\u043d \u044d\u043a\u0440\u0430\u043d \u0435\u0434\u0438\u043d\u0438\u0447\u043d\u043e\u0439 \u043d\u043e\u0432\u043e\u0441\u0442\u0438, \u0430 \u043c\u043e\u0434\u0435\u043b\u0438 \u0443\u0436\u0435 \u0432\u0438\u0441\u044f\u0442 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438:<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/ra\/ms\/ra\/ramsrarpwaj5p2zq2c5w0gc91ps.png\" width=\"50%\"><\/p>\n<p>  \u0427\u0442\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0447\u0442\u043e\u0431\u044b \u043e\u0431\u043b\u0435\u0433\u0447\u0438\u0442\u044c \u0441\u0435\u0431\u0435 \u0436\u0438\u0437\u043d\u044c? <br \/>  \u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u0432\u0441\u043f\u043e\u043c\u043d\u0438\u043c, \u0447\u0442\u043e View \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u043d\u0435 \u0432 \u0432\u0430\u043a\u0443\u0443\u043c\u0435, \u0430 \u0440\u0435\u043d\u0434\u0435\u0440\u044f\u0442\u0441\u044f \u0432 UIHostingController.   <\/p>\n<pre><code class=\"swift\">open class UIHostingController&lt;Content&gt; : UIViewController where Content : View {      public init(rootView: Content)      public var rootView: Content \/\/... } <\/code><\/pre>\n<p>  \u0410 \u044d\u0442\u043e UIViewController. \u0417\u043d\u0430\u0447\u0438\u0442, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435. \u041c\u044b \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0435\u043c \u0432\u0441\u044e \u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u0437\u0430 \u043f\u0435\u0440\u0435\u0445\u043e\u0434 \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 View \u0432\u043d\u0443\u0442\u0440\u0438 \u043d\u043e\u0432\u043e\u0433\u043e UIHostingController \u043d\u0430 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e View. \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043c\u043e\u0434\u0443\u043b\u0438 \u043d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u0438 \u0438 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0435\u043c \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0438\u0437 \u043d\u0430\u0448\u0435\u0433\u043e View.<\/p>\n<p>  \u041d\u0430\u0432\u0438\u0433\u0430\u0442\u043e\u0440, \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0439 \u0441 UIViewController, \u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u0442\u0430\u043a\u043e\u0439 \u0432\u0438\u0434:   <\/p>\n<pre><code class=\"swift\">class Navigator {     private init(){}          static let shared = Navigator()          private weak var view: UIViewController?          internal weak var nc: UINavigationController?             func setup(view: UIViewController) {         self.view = view     }         internal func open&lt;Content:View&gt;(screen: Content.Type, _ data: Any? = nil) {      if let vc = ModuleConfig.shared.config(screen: screen)?         .createScreen(data) {         self.nc?.pushViewController(vc, animated: true)         }    } <\/code><\/pre>\n<p>  \u041f\u043e \u0442\u043e\u043c\u0443 \u0436\u0435 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0443 \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0444\u0430\u0431\u0440\u0438\u043a\u0443 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0442\u043e\u0440\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u043c \u0432\u044b\u0434\u0430\u0432\u0430\u0442\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0442\u043e\u0440\u0430 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e \u043c\u043e\u0434\u0443\u043b\u044f:  <\/p>\n<pre><code class=\"swift\">protocol IConfugator: class {     func createScreen(_ data: Any?)-&gt;UIViewController }  class ModuleConfig{     private init(){}     static let shared = ModuleConfig()          func config&lt;Content:View&gt;(screen: Content.Type)-&gt;IConfugator? {         if screen == NewsListView.self {             return NewsListConfigurator.shared         }       \/\/\u043a\u043e\u0434 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e         return nil     } } <\/code><\/pre>\n<p>  \u041d\u0430\u0432\u0438\u0433\u0430\u0442\u043e\u0440 \u043f\u043e \u0442\u0438\u043f\u0443 \u044d\u043a\u0440\u0430\u043d\u0430 \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u0442 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0442\u043e\u0440 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e \u043c\u043e\u0434\u0443\u043b\u044f, \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442 \u0435\u043c\u0443 \u0432\u0441\u044e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e.  <\/p>\n<pre><code class=\"swift\">class NewsListConfigurator: IConfugator {     static let shared = NewsListConfigurator()          func createScreen(_ data: Any?) -&gt; UIViewController {          var view = NewsListView()         let presenter = NewsListPresenter()          let interactor = NewsListInteractor()                  interactor.output = presenter         presenter.output = view         view.output = interactor                  let vc = UIHostingController&lt;ContainerView&lt;NewsListView&gt;&gt;                     (rootView: ContainerView(content: view))         return vc     } } <\/code><\/pre>\n<p>  \u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0442\u043e\u0440 \u043e\u0442\u0434\u0430\u0435\u0442 UIViewController, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 Navigator \u0438 \u043a\u043b\u0430\u0434\u0435\u0442 \u0432 \u043e\u0431\u0449\u0438\u0439 \u0441\u0442\u0435\u043a UINavigationController.<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/1n\/je\/mw\/1njemwtm7eb3mjxqibdyh7etqqm.png\" width=\"50%\"><br \/>  \u0417\u0430\u043c\u0435\u043d\u0438\u043c NavigationLink \u0432 \u043a\u043e\u0434\u0435 \u043d\u0430 \u0432\u044b\u0437\u043e\u0432 Navigator. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0442\u0440\u0438\u0433\u0433\u0435\u0440\u0430 \u0443 \u043d\u0430\u0441 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u043d\u0430\u0436\u0430\u0442\u0438\u044f \u043d\u0430 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0441\u043f\u0438\u0441\u043a\u0430:  <\/p>\n<pre><code class=\"swift\">  List(model.data) { item in             NewsItemRow(data: item)                 .onTapGesture {                 Navigator.shared.open(screen: NewsItemView.self, item)             }         } <\/code><\/pre>\n<p>  \u041d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u043c\u0435\u0448\u0430\u0435\u0442 \u043d\u0430\u043c \u0442\u0430\u043a\u0438\u043c \u0436\u0435 \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c Navigator \u0432 \u043b\u044e\u0431\u043e\u043c \u043c\u0435\u0442\u043e\u0434\u0435 View. \u041d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u043d\u0443\u0442\u0440\u0438 body.<br \/>  \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u043a\u043e\u0434 \u0441\u0442\u0430\u043b \u043e\u0449\u0443\u0442\u0438\u043c\u043e \u0447\u0438\u0449\u0435, \u043c\u044b \u0435\u0449\u0435 \u0438 \u0440\u0430\u0437\u0433\u0440\u0443\u0437\u0438\u043b\u0438 \u043f\u0430\u043c\u044f\u0442\u044c. \u0412\u0435\u0434\u044c \u043f\u0440\u0438 \u0442\u0430\u043a\u043e\u043c \u043f\u043e\u0434\u0445\u043e\u0434\u0435 View \u0441\u043e\u0437\u0434\u0430\u0441\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438 \u0432\u044b\u0437\u043e\u0432\u0435.<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/_7\/bb\/p8\/_7bbp8aujaqoftrfjo0jywsmrfg.png\" width=\"50%\"><\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u0448\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 SwiftUI \u043f\u0440\u043e\u0449\u0435 \u0440\u0430\u0441\u0448\u0438\u0440\u044f\u0442\u044c \u0438 \u043c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u0442\u044c. \u041a\u043e\u0434 \u0447\u0438\u0441\u0442\u044b\u0439 \u0438 \u043a\u0440\u0430\u0441\u0438\u0432\u044b\u0439.<br \/>  \u041a\u043e\u0434 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0432\u044b \u043d\u0430\u0439\u0434\u0435\u0442\u0435 \u043f\u043e <a href=\"https:\/\/github.com\/anioutkazharkova\/swiftui_tutorials_guide\" rel=\"nofollow\">\u0441\u0441\u044b\u043b\u043a\u0435<\/a><\/p>\n<p>  \u0412 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0440\u0430\u0437 \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043f\u0440\u043e \u0431\u043e\u043b\u0435\u0435 \u0433\u043b\u0443\u0431\u043e\u043a\u043e\u0435 \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u0435 Combine. <\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/500492\/\"> https:\/\/habr.com\/ru\/post\/500492\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/500492\/\">\u0414\u043e\u0431\u0440\u043e\u0433\u043e \u0432\u0441\u0435\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0441\u0443\u0442\u043e\u043a! \u0421 \u0432\u0430\u043c\u0438 \u044f, \u0410\u043d\u043d\u0430 \u0416\u0430\u0440\u043a\u043e\u0432\u0430, \u0432\u0435\u0434\u0443\u0449\u0438\u0439 \u043c\u043e\u0431\u0438\u043b\u044c\u043d\u044b\u0439 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438 <a href=\"https:\/\/usetech.ru\/\" rel=\"nofollow\">\u00abUsetech\u00bb <\/a><br \/>  \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043e\u0431 \u0435\u0449\u0435 \u043e\u0434\u043d\u043e\u043c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u043c \u043c\u043e\u043c\u0435\u043d\u0442\u0435 \u0432 SwiftUI, \u043e \u043d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u0438. <br \/>  \u0415\u0441\u043b\u0438 \u0432\u044b \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u043b\u0438 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0435 \u0441\u0442\u0430\u0442\u044c\u0438 \u0446\u0438\u043a\u043b\u0430, \u0442\u043e \u043c\u043e\u0436\u0435\u0442\u0435 \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u0441 \u043d\u0438\u043c\u0438 \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435:<br \/>  <a href=\"https:\/\/habr.com\/ru\/post\/500194\/\">\u0447\u0430\u0441\u0442\u044c 1<\/a><br \/>  <a href=\"https:\/\/habr.com\/ru\/post\/500386\/\">\u0447\u0430\u0441\u0442\u044c 2<\/a><br \/>  <a href=\"https:\/\/habr.com\/ru\/post\/500470\/\">\u0447\u0430\u0441\u0442\u044c 3<\/a><\/p>\n<p>  \u0421 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435\u043c \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0432\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u0438 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u043e\u043c \u043a \u0434\u0435\u043a\u043b\u0430\u0440\u0430\u0442\u0438\u0432\u043d\u043e\u043c\u0443 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u0443 \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u043e\u0441\u044c \u0438 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u0435\u0439 \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 SwiftUI. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 UIViewContoller \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u043e\u0442\u0440\u0438\u0446\u0430\u0435\u0442\u0441\u044f, UINavigationController \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f. \u041d\u0430 \u0441\u043c\u0435\u043d\u0443 \u0435\u043c\u0443 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 NavigationView.  <\/p>\n<pre><code class=\"swift\">@available(iOS 13.0, OSX 10.15, tvOS 13.0, *) @available(watchOS, unavailable) public struct NavigationView&lt;Content&gt; : View where Content : View {      public init(@ViewBuilder content: () -&gt; Content)      \/\/.... } <\/code><\/pre>\n<p>   \u041f\u043e \u0441\u0443\u0442\u0438 \u043e\u0431\u0435\u0440\u0442\u043a\u0430 \u043d\u0430\u0434 UINavigationController \u0438 \u0435\u0433\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u043e\u043c.   <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-303060","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/303060","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=303060"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/303060\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=303060"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=303060"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=303060"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}