{"id":315390,"date":"2020-12-23T15:00:16","date_gmt":"2020-12-23T15:00:16","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=315390"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=315390","title":{"rendered":"\u041f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0430 SwiftUI \u0432 AppStore \u2013 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438"},"content":{"rendered":"\n<div class=\"post__text post__text_v2\" id=\"post-content-body\">\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/12e\/147\/898\/12e147898fa0a420d54efcb82566333b.png\" width=\"1024\" height=\"600\"><figcaption><\/figcaption><\/figure>\n<p>SwiftUI \u2013 \u044d\u0442\u043e \u043c\u043e\u043b\u043e\u0434\u0430\u044f \u0438 \u043f\u043e\u043a\u0430 \u0447\u0442\u043e \u043d\u0435 \u0441\u043e\u0432\u0441\u0435\u043c \u0438\u0437\u0443\u0447\u0435\u043d\u043d\u0430\u044f \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u044f. \u0421 \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b, \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e \u0434\u043b\u044f \u0442\u0432\u043e\u0440\u0447\u0435\u0441\u0442\u0432\u0430 \u0438 \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f, \u0430 \u0441 \u0434\u0440\u0443\u0433\u043e\u0439 \u2013 \u043d\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e\u0441\u0442\u044c, \u043d\u0435\u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0438 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b.<\/p>\n<p>\u0422\u0430\u043a \u043b\u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0438\u0441\u0430\u0442\u044c \u043d\u0430 SwiftUI, \u043a\u0430\u043a \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442 \u043d\u0430 WWDC? \u042f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u043e \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044f\u0445, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0441\u044f \u043b\u0438\u0447\u043d\u043e \u044f \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u041e\u043d\u043e \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043e \u043d\u0430 SwiftUI \u0438 \u0432\u044b\u043b\u043e\u0436\u0435\u043d\u043e \u0432 <a href=\"https:\/\/apps.apple.com\/ru\/app\/paibo\/id1530328217\" rel=\"noopener noreferrer nofollow\">App Store<\/a>.<\/p>\n<p>\u041a\u0430\u043a\u0438\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u043c\u043e\u0433\u0443\u0442 \u0432\u0441\u0442\u0440\u0435\u0442\u0438\u0442\u044c\u0441\u044f \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438? \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0442\u044c\u0441\u044f.<\/p>\n<h2>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430 View <\/h2>\n<p>\u0413\u043b\u0430\u0432\u043d\u0430\u044f \u0438 \u0441\u0430\u043c\u0430\u044f \u0431\u043e\u043b\u044c\u0448\u0430\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043d\u0430\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u0442 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u043f\u043e\u0447\u0442\u0438 \u043d\u0430 \u043b\u044e\u0431\u043e\u0439 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434. \u041c\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u043e \u043d\u0430 MVI, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u0431\u0443\u0434\u0443 \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u044d\u0442\u043e\u0439 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b. \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043e\u0431 MVI \u044f \u043f\u0438\u0441\u0430\u043b \u0432 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/512542\/\" rel=\"noopener noreferrer nofollow\">MVI \u0438 SwiftUI \u2013 \u043e\u0434\u043d\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435<\/a><\/p>\n<p>\u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u0434\u0435\u043b\u0430\u044e \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043e\u0442\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u0435:<\/p>\n<h4>@ObservedObject \u0438 @StateObject<\/h4>\n<p>\u0412 MVI \u0435\u0441\u0442\u044c \u043c\u043e\u0434\u0443\u043b\u044c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u0431\u0438\u0437\u043d\u0435\u0441 \u043b\u043e\u0433\u0438\u043a\u0443, \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f Intent. \u0423 View \u043d\u0430 Intent \u0435\u0441\u0442\u044c \u0441\u0441\u044b\u043b\u043a\u0430.<\/p>\n<pre><code class=\"swift\">struct ContentView: View {      @ObservedObject var intent: ContentIntent      var body: some View {         Text(\"Hello, world!\")     } }<\/code><\/pre>\n<p>@ObservableObject \u043d\u0443\u0436\u0435\u043d \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c \u0432\u0441\u0435, \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432 \u043a\u043b\u0430\u0441\u0441\u0435 \u0438 \u0441\u043e\u043e\u0431\u0449\u0430\u0442\u044c \u043e\u0431 \u044d\u0442\u043e\u043c View, \u0430 \u0442\u043e\u0442, \u0432 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c, \u043e\u043f\u0438\u0440\u0430\u044f\u0441\u044c \u043d\u0430 \u043d\u043e\u0432\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u043c\u0435\u043d\u044f\u0435\u0442 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 UI \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432.<\/p>\n<p>\u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u043a \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0435.<\/p>\n<p>View \u0432 SwiftUI \u043e\u0431\u043b\u0430\u0434\u0430\u0435\u0442 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044c\u044e \u2014 \u043a\u043e\u0433\u0434\u0430 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043f\u0435\u0440\u0435\u0440\u0438\u0441\u043e\u0432\u0430\u0442\u044c View, \u043e\u043d  \u043f\u0435\u0440\u0435\u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f, \u0432 \u0442\u0430\u043a\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 init \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e. \u041a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e, View \u043f\u0435\u0440\u0435\u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f, \u043a\u043e\u0433\u0434\u0430 \u0443 \u0434\u0440\u0443\u0433\u043e\u0439 View, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u0442\u043e\u0438\u0442 \u043f\u043e \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u0438 \u0432\u044b\u0448\u0435, \u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f \u0434\u0430\u043d\u043d\u044b\u0435.<\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u0440\u0438\u043c\u0435\u0440 \u043d\u0438\u0436\u0435, \u0433\u0434\u0435 \u043e\u0434\u043d\u0430 \u0438\u0437 View \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e \u043f\u0435\u0440\u0435\u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f.<\/p>\n<pre><code class=\"swift\">\/\/ MARK: - Screen ContentView struct ContentView: View {      @State var isNestScreenVisible = false     @State var seconds = \"0\"      var body: some View {         NavigationView {             VStack(spacing: 16) {                 Text(\"Seconds: \\(seconds)\")                 NavigationLink(\"Next screen\", destination: NextView(), isActive: $isNestScreenVisible)             }         }.onAppear {             Timer.scheduledTimer(withTimeInterval: 1, repeats: true) { timer in                 self.seconds = String(Int(Date().timeIntervalSince1970) % 60)             }         }     } }  \/\/ MARK: - Scren NextView struct NextView: View {      @ObservedObject var intent: NextIntent      init() {         intent = ContentIntent()          print(\"init NextView\")     }      var body: some View {         Text(\"Hello Weold!\")     } <\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u043e\u0442\u043a\u0440\u044b\u0442\u044c \u044d\u043a\u0440\u0430\u043d NextView, \u0442\u043e \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u0443 \u043d\u0435\u0433\u043e \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u043a\u0430\u0436\u0434\u0443\u044e \u0441\u0435\u043a\u0443\u043d\u0434\u0443. \u0412 \u043a\u043e\u043d\u0441\u043e\u043b\u0438 \u043c\u044b \u0443\u0432\u0438\u0434\u0438\u043c:<\/p>\n<pre><code class=\"bash\">init NextView init NextView init NextView init NextView init NextView init NextView init NextView init NextView init NextView<\/code><\/pre>\n<\/p>\n<p>\u041a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u043a\u043e\u0433\u0434\u0430 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f init, \u0432\u0441\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0432\u043d\u0443\u0442\u0440\u0438 View \u043f\u0435\u0440\u0435\u0441\u043e\u0437\u0434\u0430\u044e\u0442\u0441\u044f \u0438 \u043c\u043e\u0434\u0443\u043b\u044c, \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0449\u0438\u0439 \u0437\u0430 \u0431\u0438\u0437\u043d\u0435\u0441 \u043b\u043e\u0433\u0438\u043a\u0443 (\u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 Intent), \u0442\u0430\u043a\u0436\u0435 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u043d \u0437\u0430\u043d\u043e\u0432\u043e, \u0432\u0441\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u043d\u0435\u043c \u0441\u0431\u0440\u043e\u0441\u044f\u0442\u0441\u044f. \u0412 \u043b\u044e\u0431\u043e\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u044d\u043a\u0440\u0430\u043d \u043c\u043e\u0436\u0435\u0442 \u0432\u0435\u0440\u043d\u0443\u0442\u044c\u0441\u044f \u043a \u0441\u0432\u043e\u0435\u043c\u0443 \u043f\u0435\u0440\u0432\u043e\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u043c\u0443 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044e, \u0442.&nbsp;\u0435. \u043a \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044e \u043d\u0430 \u043c\u043e\u043c\u0435\u043d\u0442 \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u044f.<\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u044d\u0442\u043e\u0433\u043e \u043d\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u043b\u043e, @ObservedObject \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u043d\u0430 @StateObject \u0438 \u0442\u043e\u0433\u0434\u0430 Intent \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u0435\u0442 \u0437\u0430\u0432\u0438\u0441\u0435\u0442\u044c \u043e\u0442 \u0436\u0438\u0437\u043d\u0435\u043d\u043d\u043e\u0433\u043e \u0446\u0438\u043a\u043b\u0430 View.&nbsp;<\/p>\n<p>\u041a\u0430\u043a \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442?&nbsp;<\/p>\n<p>\u041a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u043a\u043e\u0433\u0434\u0430 View \u043f\u0435\u0440\u0435\u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f, \u0443 \u0432\u0441\u0435\u0445 \u043c\u043e\u0434\u0443\u043b\u0435\u0439 \u0432 \u043d\u0435\u043c \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 (\u0432 MVI \u044d\u0442\u043e Intent \u0438 Model, \u0432 MVVM \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 ViewModel).<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/baa\/eac\/3b8\/baaeac3b8b00fe28103b080314df774d\" width=\"2223\" height=\"1106\"><figcaption><\/figcaption><\/figure>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a Intent \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d, \u043e\u043d \u043f\u043e\u043c\u0435\u0449\u0430\u0435\u0442\u0441\u044f \u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 @StateObject; \u0435\u0441\u043b\u0438 \u0442\u0430\u043c \u0443\u0436\u0435 \u043b\u0435\u0436\u0438\u0442 \u043e\u0431\u044a\u0435\u043a\u0442 Intent, \u0442\u043e \u043d\u043e\u0432\u044b\u0439 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0439 Intent \u0443\u0434\u0430\u043b\u044f\u0435\u0442\u0441\u044f. @StateObject \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u0445\u043e\u0436 \u043d\u0430 Singleton, \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u043d \u0443\u0434\u0430\u043b\u044f\u0435\u0442\u0441\u044f \u0438\u0437 \u043f\u0430\u043c\u044f\u0442\u0438.<\/p>\n<blockquote>\n<p><em>\u0423\u0447\u0438\u0442\u044b\u0432\u0430\u044f, \u0447\u0442\u043e \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u0443 Intent \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e, \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u043e\u043d \u0431\u0443\u0434\u0435\u0442 @StateObject, \u0432 init \u043d\u0435 \u0441\u0442\u043e\u0438\u0442 \u043f\u0438\u0441\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0438 \u043b\u044e\u0431\u0443\u044e \u0434\u0440\u0443\u0433\u0443\u044e \u043b\u043e\u0433\u0438\u043a\u0443 \u043a\u0440\u043e\u043c\u0435 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0432\u043d\u0443\u0442\u0440\u0438 Intent. <\/em><\/p>\n<\/p>\n<p><em>@StateObject \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u0441 \u0432\u0435\u0440\u0441\u0438\u0438 iOS 14.<\/em><\/p>\n<\/blockquote>\n<h4>\u041c\u043e\u0436\u043d\u043e \u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c @ObservedObject, \u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0435\u0433\u043e Singleton?<\/h4>\n<p>\u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043f\u043e\u0434\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0442\u044c \u0443\u0436\u0435 \u0433\u043e\u0442\u043e\u0432\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442.<\/p>\n<pre><code class=\"swift\">struct ContentView: View {      @ObservedObject var intent: ContentInten      init() {         self.intent = ContentInten.shared         let model = ContentModel()         self.intent.update(model: model)     }          var body: some View {         Text(\"Hello, world!\")     } <\/code><\/pre>\n<p>\u041e\u0434\u043d\u0430 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0437\u0430\u043a\u0440\u043e\u0435\u0442\u0441\u044f, \u043d\u043e \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u0443\u0442 \u0434\u0440\u0443\u0433\u0438\u0435:<\/p>\n<ol>\n<li>\n<p>\u041f\u0440\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 Intent \u043f\u0440\u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0431\u0443\u0434\u0443\u0442 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0442\u044c \u0432\u043e\u043f\u0440\u043e\u0441\u044b (\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u043b\u0438 \u0441\u0435\u0439\u0447\u0430\u0441 \u0434\u0430\u043d\u043d\u044b\u0435, \u0435\u0441\u043b\u0438 \u043e\u043d\u0438 \u0443\u0436\u0435 \u0435\u0441\u0442\u044c, \u043d\u0443\u0436\u043d\u043e \u043b\u0438 \u0438\u0445 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0438 \u0442.&nbsp;\u0434.)<\/p>\n<\/li>\n<li>\n<p>Singleton \u043c\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u043c \u0443\u043d\u0438\u0447\u0442\u043e\u0436\u0438\u0442\u044c \u0438 \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u0434\u0435\u0440\u0436\u0430\u0442\u044c\u0441\u044f \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 \u0432\u0441\u044e \u0441\u0435\u0441\u0441\u0438\u044e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f&nbsp;<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u0432\u0442\u043e\u0440\u043e\u0433\u043e, \u0442\u0440\u0435\u0442\u044c\u0435\u0433\u043e \u0438 \u0434\u0440\u0443\u0433\u0438\u0445 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u044d\u043a\u0440\u0430\u043d\u043e\u0432 \u0443 \u043d\u0430\u0441 \u0431\u0443\u0434\u0435\u0442 \u043e\u0434\u0438\u043d Singleton \u043d\u0430 \u0432\u0441\u0435 \u044d\u0442\u0438 \u044d\u043a\u0440\u0430\u043d\u044b.&nbsp;<\/p>\n<\/li>\n<\/ol>\n<p>SwiftUI \u0432 iOS 14 \u0441\u0438\u043b\u044c\u043d\u043e \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0431\u043e\u0440\u043e\u0442\u044c\u0441\u044f \u0441 \u044d\u0442\u0438\u043c\u0438 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430\u043c\u0438 \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439, \u0435\u0441\u0442\u044c \u0441\u043c\u044b\u0441\u043b \u0434\u0435\u043b\u0430\u0442\u044c \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u0438 iOS 14 \u0434\u043b\u044f \u044d\u043a\u0440\u0430\u043d\u043e\u0432 SwiftUI.<\/p>\n<h4>\u041e\u0431\u044a\u0435\u043a\u0442 @StateObject \u043d\u0435\u043b\u044c\u0437\u044f \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u043d\u0443\u0442\u0440\u0438 init View<\/h4>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/b55\/867\/daa\/b55867daaef7ce7d923bb0357d5b0d68\" width=\"1414\" height=\"250\"><figcaption><\/figcaption><\/figure>\n<p>\u0415\u0449\u0435 \u043e\u0434\u043d\u0430 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044c. Intent \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d \u0432\u043d\u0435 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430 View. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u0432 \u043a\u043e\u0442\u043e\u0440\u0443\u044e, \u0435\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u043e, \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435.<\/p>\n<pre><code class=\"swift\">struct ContentView: View {      @StateObject var intent: ContentInten      var body: some View {         Text(\"Hello, world!\")     }      static func build() -&gt; some View {         let model = ContentModel()         let intent = ContentInten(model: model)         return ContentView(intent: intent)     } <\/code><\/pre>\n<\/p>\n<p>\u0412 \u043e\u0431\u0449\u0435\u043c, \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u043c\u043d\u043e\u0433\u043e \u043d\u0435\u0443\u0434\u043e\u0431\u0441\u0442\u0432 \u0438 \u043d\u0430\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u0438\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u043d\u0430 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0443 \u0434\u043b\u044f iOS 13.<\/p>\n<h2>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 onAppear \u0438 onDisappear<\/h2>\n<p>\u041c\u044b \u043d\u0435 \u0437\u043d\u0430\u0435\u043c, \u043a\u043e\u0433\u0434\u0430 View \u0443\u0434\u0430\u043b\u0435\u043d \u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0435\u0433\u043e \u043d\u0435 \u0432\u0438\u0434\u0438\u0442, \u0438\u043b\u0438 \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442, \u043a\u043e\u0433\u0434\u0430 View \u0432\u043f\u0435\u0440\u0432\u044b\u0435 \u043f\u043e\u043a\u0430\u0437\u0430\u043d. \u0415\u0441\u0442\u044c \u043c\u043d\u0435\u043d\u0438\u0435 \u0447\u0442\u043e, \u0447\u0442\u043e onAppear \u0438 onDisappear \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u043e\u0434\u0438\u043d \u0440\u0430\u0437, \u043a\u043e\u0433\u0434\u0430 \u044d\u043a\u0440\u0430\u043d \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u0438 \u043a\u043e\u0433\u0434\u0430 \u043e\u043d \u0443\u0434\u0430\u043b\u044f\u0435\u0442\u0441\u044f. \u042d\u0442\u043e \u043d\u0435 \u0442\u0430\u043a. \u0418 \u0442\u043e\u0442 \u0438 \u0434\u0440\u0443\u0433\u043e\u0439 \u043c\u0435\u0442\u043e\u0434 \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0437\u0432\u0430\u0442\u044c\u0441\u044f \u0431\u043e\u043b\u0435\u0435 \u043e\u0434\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u0430 \u0443 \u043e\u0434\u043d\u043e\u0433\u043e \u044d\u043a\u0440\u0430\u043d\u0430.&nbsp;<\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u0440\u0438\u043c\u0435\u0440<\/p>\n<pre><code class=\"swift\">struct ContentView: View {      @State var isVisibleHomeScreen = false      var body: some View {         NavigationView {             VStack {                 Text(\"Hello, world!\")                  NavigationLink(destination: Text(\"Screen Home\"),                                isActive: $isVisibleHomeScreen,                                label: { Text(\"Open screen\") })             }.onAppear {                 print(\"onAppear was called\")             }.onDisappear {                 print(\"onDisappear was called\")             }         }     } <\/code><\/pre>\n<p>\u041f\u0440\u0438 \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u0438 \u0438 \u0437\u0430\u043a\u0440\u044b\u0442\u0438\u0438 \u044d\u043a\u0440\u0430\u043d\u0430 <u>\u0432\u043d\u0443\u0442\u0440\u0438 NavigationView<\/u> \u044d\u0442\u0438 \u043c\u0435\u0442\u043e\u0434\u044b \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u044e\u0442 \u0431\u043e\u043b\u0435\u0435 \u043e\u0434\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u0430. \u0412 \u043a\u043e\u043d\u0441\u043e\u043b\u0438 \u043c\u044b \u0443\u0432\u0438\u0434\u0438\u043c:<\/p>\n<pre><code class=\"bash\">onDisappear was called onAppear was called<\/code><\/pre>\n<\/p>\n<p>\u041a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e, NavigationView \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0443 \u043e\u0434\u043d\u043e\u0433\u043e \u044d\u043a\u0440\u0430\u043d\u0430, \u043f\u0435\u0440\u0432\u043e\u0433\u043e, \u0430 \u0443 \u0432\u0441\u0435\u0445 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0443\u0436\u0435 \u043d\u0435\u0442. onAppear \u0438 onDisappear \u0431\u0443\u0434\u0443\u0442 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u044d\u043a\u0440\u0430\u043d\u0430\u0445 \u0431\u043e\u043b\u044c\u0448\u0435 \u043e\u0434\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u0430. \u042d\u0442\u043e \u043d\u0430\u0434\u043e \u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0432 \u0433\u043e\u043b\u043e\u0432\u0435 \u043f\u0440\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u0430\u043a\u0438\u0445-\u043b\u0438\u0431\u043e \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u043d\u044b\u0445 \u0440\u0435\u0448\u0435\u043d\u0438\u0439.<\/p>\n<h2>\u041d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u044f<\/h2>\n<p>\u041a\u0430\u043a \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u044e \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u0441\u043e SwiftUI? \u042d\u0442\u043e\u0442 \u0432\u043e\u043f\u0440\u043e\u0441 \u0441\u0442\u043e\u0438\u0442 \u043e\u0441\u043e\u0431\u043e \u043e\u0441\u0442\u0440\u043e, \u0442\u0430\u043a \u043a\u0430\u043a \u043d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u044f \u0442\u0443\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043f\u043e \u0434\u0440\u0443\u0433\u0438\u043c \u043f\u0440\u0430\u0432\u0438\u043b\u0430\u043c, \u0438 \u0432\u0435\u0441\u044c \u043d\u0430\u043a\u043e\u043f\u043b\u0435\u043d\u043d\u044b\u0439 \u043e\u043f\u044b\u0442 \u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u0430 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 UIKit \u0442\u0443\u0442 \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u041c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u043d\u0435\u043c\u0430\u043b\u043e \u0441\u0442\u0430\u0442\u0435\u0439 \u0438 \u0432\u0438\u0434\u0435\u043e, \u043f\u043e\u0441\u0432\u044f\u0449\u0435\u043d\u043d\u044b\u0445 \u0442\u0435\u043c\u0435 \u043d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u0438 \u0432 SwiftUI. \u0412\u0441\u0435, \u0447\u0442\u043e \u044f \u0432\u0438\u0434\u0435\u043b, \u0438\u043b\u0438 \u043d\u0435\u0443\u0434\u043e\u0431\u043d\u043e, \u0438\u043b\u0438 \u0433\u0440\u043e\u043c\u043e\u0437\u0434\u043a\u043e. \u042f \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u0441\u0432\u043e\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442, \u0447\u0442\u043e\u0431\u044b \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u044b \u0434\u0435\u043b\u0430\u043b\u0438\u0441\u044c \u0440\u043e\u0432\u043d\u043e \u0442\u0430\u043a, \u043a\u0430\u043a \u043d\u0430\u043c \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u043b\u0438 \u043d\u0430 WWDC. \u042d\u0442\u043e \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u043d\u0435\u0441\u043b\u043e\u0436\u043d\u043e, \u0432\u0441\u044e \u043b\u043e\u0433\u0438\u043a\u0443 \u043d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u0438 \u043d\u0443\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0432\u044b\u043d\u0435\u0441\u0442\u0438 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 &#171;some View&#187;.&nbsp;<\/p>\n<p>\u0412\u043e \u0432\u0440\u0435\u043c\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0442 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0440\u043e\u0443\u0442\u0435\u0440\u0430 \u043f\u043e\u043a\u0430\u0437\u0430\u043b \u0441\u0435\u0431\u044f \u043e\u0447\u0435\u043d\u044c \u0445\u043e\u0440\u043e\u0448\u043e, \u0434\u0430\u0436\u0435 \u043b\u0443\u0447\u0448\u0435, \u0447\u0435\u043c MVI. \u0422\u0430\u043a \u043a\u0430\u043a \u044d\u0442\u043e \u0431\u043e\u043b\u044c\u0448\u0430\u044f \u0442\u0435\u043c\u0430, \u043f\u043e\u0434 \u0441\u043f\u043e\u043b\u0435\u0440\u043e\u043c \u044f \u043e\u0441\u0442\u0430\u0432\u043b\u044e \u043f\u0440\u0438\u043c\u0435\u0440, \u0430 \u0441\u0430\u043c \u043f\u043e\u0434\u0445\u043e\u0434, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u043e\u043f\u0438\u0448\u0443 \u0432 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435.<\/p>\n<details class=\"spoiler\">\n<summary>Router<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"swift\">\/\/  ContentRouter.swift \/\/ \/\/  Copyright \u00a9 2020 Vyacheslav Ansimov. All rights reserved. \/\/ import SwiftUI import Combine  \/\/ MARK: - Realization struct ContentRouter: View {      enum ScreenType {         case sheetScreen(value: String)         case navigationScreen(value: String)         case exit     }      private class ScreenTypeHolder: ObservableObject {         @Published var type: ScreenType?     }      \/\/ API     let screen: PassthroughSubject&lt;ScreenType, Never&gt;      \/\/ private     @Environment(\\.presentationMode) private var presentationMode     @StateObject private var screenType = ScreenTypeHolder()      \/\/ Life cycle     var body: some View {         displayView().onReceive(screen) { self.screenType.type = $0 }     }      private func displayView() -&gt; some View {         let isVisible = Binding&lt;Bool&gt;(get: { screenType.type != nil },                                       set: { if !$0 { screenType.type = nil } })         \/\/ Screens         switch screenType.type {         case .sheetScreen(let value):             return AnyView(                 Spacer().sheet(isPresented: isVisible) {                     Text(value)                 }             )          case .navigationScreen(let value):             return AnyView (                 NavigationLink(\"\", destination: Text(value), isActive: isVisible)             )          case .exit:             presentationMode.wrappedValue.dismiss()             return AnyView(EmptyView())          case .none:             return AnyView(EmptyView())         }     } }  \/\/ MARK: - Example struct ContentRouter_Previews: PreviewProvider {     static let routeSubject = PassthroughSubject&lt;ContentRouter.ScreenType, Never&gt;()      static var previews: some View {         NavigationView {             VStack {                 Button(action: {                     self.routeSubject.send(.sheetScreen(value: \"Hello World!\"))                 }, label: { Text(\"Display Sheet Screen\") })                  Button(action: {                     self.routeSubject.send(.navigationScreen(value: \"Hello World!\"))                 }, label: { Text(\"Display NavigationLink Screen\") })             }             .overlay(ContentRouter(screen: routeSubject))         }     } }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<h2>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u043f\u0440\u043e\u043a\u0441\u0438<\/h2>\n<p>Property wrapper (State, Binding, ObservedObject \u0438 \u0434\u0440.) \u0434\u0430\u044e\u0442 SwiftUI \u0440\u0435\u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u0438 \u0438 \u0434\u0435\u043b\u0430\u0435\u0442 \u0443\u0434\u043e\u0431\u043d\u044b\u043c \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 UI.<\/p>\n<p>\u0410 \u0435\u0441\u043b\u0438 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0432\u044b\u043d\u0435\u0441\u0442\u0438 \u044d\u0442\u0438 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441. \u0422\u043e\u0433\u0434\u0430 \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u043a\u043b\u0430\u0441\u0441, \u043f\u043e\u0434\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u0434 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b ObservableObject \u0438 \u043f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u043e View<\/p>\n<pre><code class=\"swift\">\/\/ MARK: Model class ContentModel: ObservableObject {     @Publised var title = \"Hello World!\" }  \/\/ MARK: View struct ContentView: View {      @ObservedObject var model:  ContentModel      var body: some View {         Text(model.title)     } }<\/code><\/pre>\n<p>\u0410 \u0435\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u043e \u044d\u0442\u043e\u0442 \u043a\u043b\u0430\u0441\u0441 \u0441\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430\u043c\u0438 \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0442\u0438 \u0432 \u0434\u0440\u0443\u0433\u043e\u0439 \u043c\u043e\u0434\u0443\u043b\u044c, \u0434\u0440\u0443\u0433\u043e\u0439 \u043a\u043b\u0430\u0441\u0441? \u0422\u0443\u0442 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u044e\u0442 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0438.<\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u0440\u0438\u043c\u0435\u0440 \u0441 Intent. \u041d\u0430\u0448 \u043a\u043b\u0430\u0441\u0441 \u0441\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430\u043c\u0438 \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0442\u0430\u043c, \u043d\u043e \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0432\u0441\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0441\u0432\u043e\u0439\u0441\u0442\u0432 \u0434\u043e\u043b\u0436\u0435\u043d \u0432\u0438\u0434\u0435\u0442\u044c View.<\/p>\n<pre><code class=\"swift\">\/\/ MARK: View struct ContentView: View {    @StateObject var intent:  ContentIntent    var body: some View {       Text(intent.model .title).onAppear {           self.intent.onAppear()       }   } }  \/\/ MARK: Intent class ContentIntent {    let model:  ContentModel    ...     func onAppear() {     model.title = \"Hello World!\"   } }  \/\/ MARK: Model class ContentModel: ObservableObject {   @Published var title = \"Loaded\" }<\/code><\/pre>\n<p>\u0412 \u043f\u0440\u0438\u043c\u0435\u0440\u0435, UI \u044d\u043b\u0435\u043c\u0435\u043d\u0442 Text \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0431\u0443\u0434\u0435\u0442 \u0432\u0438\u0434\u0435\u0442\u044c \u043d\u0430\u0434\u043f\u0438\u0441\u044c &#171;Loaded&#187;, \u0434\u0430\u0436\u0435 \u043f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e \u043a\u0430\u043a \u0432\u0441\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0431\u0443\u0434\u0443\u0442 \u0432\u044b\u0437\u0432\u0430\u043d\u044b. \u0414\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u043f\u043e\u043c\u0435\u043d\u044f\u0442\u044c<\/p>\n<pre><code class=\"swift\">let model: ContentModel<\/code><\/pre>\n<p>\u043d\u0430&nbsp;<\/p>\n<pre><code class=\"swift\">@Published var model: ContentModel<\/code><\/pre>\n<p>\u0420\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043d\u0435 \u0431\u0443\u0434\u0435\u0442. ObservableObject \u0443 Model \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442 \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u0432 Intent \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u0443 \u043d\u0435\u0433\u043e \u0447\u0442\u043e-\u0442\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u043e\u0441\u044c, \u0430 \u043d\u0435 \u0432\u043e View.&nbsp;<\/p>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b View \u0443\u0437\u043d\u0430\u043b \u0447\u0442\u043e \u0432 Model \u0447\u0442\u043e-\u0442\u043e \u043f\u043e\u043c\u0435\u043d\u044f\u043b\u043e\u0441\u044c, \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u043d\u0443\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0438\u0437 Intent \u0434\u0430\u043b\u044c\u0448\u0435. \u0427\u0442\u043e\u0431\u044b \u0437\u0430\u0440\u0430\u0431\u043e\u0442\u0430\u043b\u043e, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043a\u043e\u0434 \u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0435 Intent \u0438 \u0441\u0430\u043c \u043a\u043b\u0430\u0441\u0441 \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u0442\u044c \u043f\u043e\u0434 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b ObservableObject.&nbsp;<\/p>\n<pre><code class=\"swift\">import Combine  class ContentIntent: ObservableObject {      let model: ContentModel     private var cancellable: Set&lt;AnyCancellable&gt; = []      init(model: ContentModel) {         self.model = model         cancellable.insert(model.objectWillChange.sink { [weak self] in            self?.objectWillChange.send()         })     }      ... }<\/code><\/pre>\n<p>\u041a\u043e\u0433\u0434\u0430 \u0443 Model \u0447\u0442\u043e-\u0442\u043e \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f, \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434 objectWillChange, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0437\u0432\u0435\u0449\u0430\u0435\u0442 Intent \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u0432 Model \u0435\u0441\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f. Intent \u044d\u0442\u043e\u0442 \u0438\u0432\u0435\u043d\u0442 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u0443 \u0441\u0435\u0431\u044f \u043c\u0435\u0442\u043e\u0434 objectWillChange.send(), \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u044f View \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/270\/676\/674\/270676674b2974d38f9b323972c3790d\" width=\"2648\" height=\"616\"><figcaption><\/figcaption><\/figure>\n<p>\u041f\u0440\u043e\u0442\u043e\u043a\u043e\u043b ObservableObject \u0443 Intent \u043d\u0443\u0436\u0435\u043d \u0434\u043b\u044f \u0442\u043e\u0433\u043e,\u0447\u0442\u043e\u0431\u044b \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c objectWillChange.<\/p>\n<p>\u0420\u0435\u0437\u0438\u043c\u0438\u0440\u0443\u044e. \u0415\u0441\u043b\u0438 \u0437\u0430\u0445\u043e\u0447\u0435\u0442\u0441\u044f \u0432\u044b\u043d\u0435\u0441\u0442\u0438 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 UI&nbsp; \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u0438 \u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0435\u0433\u043e \u043d\u0435 \u0432\u043e View, \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u043e\u0431\u044b\u0442\u0438\u044f.<\/p>\n<h2>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 UI<\/h2>\n<p>\u041d\u0435 \u0432\u0441\u0435, \u0447\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432 UIKit, \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432 SwiftUI. \u041c\u043d\u043e\u0433\u0438\u0445 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0432 SwiftUI \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435\u0442. \u0412 \u0442\u0430\u043a\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0438\u0437\u043e\u0431\u0440\u0435\u0442\u0430\u0442\u044c \u0432\u0435\u043b\u043e\u0441\u0438\u043f\u0435\u0434. \u0410 \u0442\u043e, \u0447\u0442\u043e \u0435\u0441\u0442\u044c, \u043f\u043b\u043e\u0445\u043e \u043a\u0430\u0441\u0442\u043e\u043c\u0438\u0437\u0438\u0440\u0443\u0435\u0442\u0441\u044f.<\/p>\n<p>\u0412\u043e\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u0441 UI \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c\u0438:<\/p>\n<ul>\n<li>\n<p>\u0413\u043e\u0442\u043e\u0432\u043e\u0433\u043e \u0430\u043d\u0430\u043b\u043e\u0433\u0430 UISearchBar \u0432 SwiftUI \u043d\u0435\u0442, \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u043f\u0438\u0441\u0430\u0442\u044c \u043b\u043e\u0433\u0438\u043a\u0443 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u0441 \u043d\u0443\u043b\u044f, \u0435\u0441\u043b\u0438 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u043f\u043e\u0438\u0441\u043a\u043e\u0432\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430.<\/p>\n<\/li>\n<li>\n<p>\u041a\u043e\u0433\u0434\u0430 \u043d\u0443\u0436\u0435\u043d UIPageControll. \u0412 SwiftUI \u0447\u0442\u043e-\u0442\u043e \u043f\u043e\u0434\u043e\u0431\u043d\u043e\u0435 \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0438\u0437 TabBar, \u043d\u043e \u043a\u0430\u0441\u0442\u043e\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f, \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0432\u043e\u0439 UIPageControll.<\/p>\n<\/li>\n<li>\n<p>PikerView: \u043d\u0435\u043b\u044c\u0437\u044f \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u0442\u044c \u0432\u044b\u0441\u043e\u0442\u0443 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430, \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0445\u043e\u0434\u0438\u0442\u044c \u0437\u0430 \u0433\u0440\u0430\u043d\u0438\u0446\u044b. \u041d\u0430 \u0440\u0438\u0441\u0443\u043d\u043a\u0435 \u043d\u0438\u0436\u0435, \u0447\u0435\u0440\u043d\u043e\u0439 \u0440\u0430\u043c\u043a\u043e\u0439 \u043f\u043e\u043a\u0430\u0437\u0430\u043d \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u0439 \u0440\u0430\u0437\u043c\u0435\u0440 PikerView. \u0412\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u0440\u0430\u0437\u043c\u0435\u0440 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u043c\u0435\u043d\u044c\u0448\u0435 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0433\u043e, \u0430 \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0432\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u043e \u0441 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u043c \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442.<\/p>\n<\/li>\n<\/ul>\n<figure class=\"float bordered full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/c11\/4af\/f4d\/c114aff4d99546c51fd1fe875a540410\" width=\"561\" height=\"259\"><figcaption><\/figcaption><\/figure>\n<ul>\n<li>\n<p>TextEditor: \u043d\u0435\u043b\u044c\u0437\u044f \u043f\u043e\u043c\u0435\u043d\u044f\u0442\u044c background, \u0442\u043e\u043b\u044c\u043a\u043e \u0431\u0435\u043b\u044b\u0439.&nbsp;<\/p>\n<\/li>\n<\/ul>\n<p>\u0418 \u044d\u0442\u043e \u0434\u0430\u043b\u0435\u043a\u043e \u043d\u0435 \u0432\u0441\u0435! \u041d\u0435 \u0432\u0441\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u043c\u043e\u0436\u043d\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u043f\u043e\u0434 \u0441\u0432\u043e\u0438 \u043d\u0443\u0436\u0434\u044b. \u0422\u0430\u043a\u0438\u0445 \u043c\u0435\u043b\u043e\u0447\u0435\u0439 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u0435\u0442\u0441\u044f \u043e\u0447\u0435\u043d\u044c \u043c\u043d\u043e\u0433\u043e. \u041f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0438\u043b\u0438 \u043c\u0438\u0440\u0438\u0442\u044c\u0441\u044f, \u0438\u043b\u0438 \u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0432\u043e\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044e \u043f\u043e\u0445\u043e\u0436 \u043d\u0430 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0439. \u0422\u0430\u043a \u043a\u0430\u043a \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u043f\u043b\u043e\u0445\u043e \u043f\u043e\u0434\u0434\u0430\u044e\u0442\u0441\u044f \u043a\u0430\u0441\u0442\u043e\u043c\u0438\u0437\u0430\u0446\u0438\u0438, \u043b\u044e\u0431\u043e\u0439 \u0448\u0430\u0433 \u0432 \u0434\u0438\u0437\u0430\u0439\u043d\u0435 \u043d\u0435 \u043f\u043e \u0433\u0430\u0439\u0434\u043b\u0430\u0439\u043d\u0430\u043c Apple \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u043d\u043e\u0441\u0438\u0442\u044c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u043f\u0440\u043e\u0431\u043b\u0435\u043c.&nbsp;<\/p>\n<h2>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h2>\n<p>\u041c\u043e\u0436\u043d\u043e \u043b\u0438 \u043a\u043e\u043c\u043c\u0435\u0440\u0447\u0435\u0441\u043a\u0438\u0439 \u043f\u0440\u043e\u0435\u043a\u0442 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0438\u0442\u044c \u043d\u0430 SwiftUI? <\/p>\n<p>\u0422\u043e\u0447\u043d\u043e \u043d\u0435\u0442.&nbsp;\u0411\u0443\u0434\u0443\u0442 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0441 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0435\u0439 \u0434\u0438\u0437\u0430\u0439\u043d\u043e\u0432, \u0431\u0443\u0434\u0443\u0442 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0442\u044c \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u043d\u044b\u0435 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0438. \u0422\u0430\u043a \u043a\u0430\u043a \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u044f \u0441\u0432\u0435\u0436\u0430\u044f, \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u043c\u043d\u043e\u0433\u043e \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c \u0438 \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u0441 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430\u043c\u0438. \u0421 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b, \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 UI \u043d\u0430 SwiftUI \u0432 \u0440\u0430\u0437\u044b \u0432\u044b\u0448\u0435, \u0447\u0435\u043c UIKit, \u0438 \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0448\u0438\u0440\u043e\u043a\u0438\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u044f\u043c\u0438 \u2013 \u0432 SwiftUI \u043e\u0447\u0435\u043d\u044c \u043a\u0440\u0430\u0441\u0438\u0432\u044b\u0435 \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0438 \u0438 \u0434\u0435\u043b\u0430\u0442\u044c \u0438\u0445 \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u043e.&nbsp;<\/p>\n<p>\u0427\u0430\u0441\u0442\u0438\u0447\u043d\u043e \u043f\u0435\u0440\u0435\u0432\u0435\u0441\u0442\u0438 \u043d\u0430 SwiftUI \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u044b\u0435 \u044d\u043a\u0440\u0430\u043d\u044b, \u044d\u043a\u0440\u0430\u043d\u044b \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0438 Welcome \u0438\u043b\u0438 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0435. \u0417\u0434\u0435\u0441\u044c SwiftUI \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0441\u0435\u0431\u044f \u0445\u043e\u0440\u043e\u0448\u043e, \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b, \u0430 \u0432\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u043e \u0441 \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u044f\u043c\u0438 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043b\u0443\u0447\u0448\u0435, \u0447\u0435\u043c UIKit. \u0422\u0430\u043a\u0436\u0435 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u043d\u0430 \u0441\u0432\u043e\u0438\u0445 \u043b\u0438\u0447\u043d\u044b\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445, \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u0438 \u0441\u043b\u043e\u0436\u043d\u044b\u0445, \u0433\u0434\u0435 \u043d\u0435\u0442 \u0436\u0435\u0441\u0442\u043a\u0438\u0445 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u0439 \u043a \u0434\u0438\u0437\u0430\u0439\u043d\u0443.&nbsp;<\/p>\n<\/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\/534608\/\"> https:\/\/habr.com\/ru\/post\/534608\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text_v2\" id=\"post-content-body\">\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>SwiftUI \u2013 \u044d\u0442\u043e \u043c\u043e\u043b\u043e\u0434\u0430\u044f \u0438 \u043f\u043e\u043a\u0430 \u0447\u0442\u043e \u043d\u0435 \u0441\u043e\u0432\u0441\u0435\u043c \u0438\u0437\u0443\u0447\u0435\u043d\u043d\u0430\u044f \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u044f. \u0421 \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b, \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e \u0434\u043b\u044f \u0442\u0432\u043e\u0440\u0447\u0435\u0441\u0442\u0432\u0430 \u0438 \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f, \u0430 \u0441 \u0434\u0440\u0443\u0433\u043e\u0439 \u2013 \u043d\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e\u0441\u0442\u044c, \u043d\u0435\u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0438 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b.<\/p>\n<p>\u0422\u0430\u043a \u043b\u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0438\u0441\u0430\u0442\u044c \u043d\u0430 SwiftUI, \u043a\u0430\u043a \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442 \u043d\u0430 WWDC? \u042f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u043e \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044f\u0445, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0441\u044f \u043b\u0438\u0447\u043d\u043e \u044f \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u041e\u043d\u043e \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043e \u043d\u0430 SwiftUI \u0438 \u0432\u044b\u043b\u043e\u0436\u0435\u043d\u043e \u0432 <a href=\"https:\/\/apps.apple.com\/ru\/app\/paibo\/id1530328217\" rel=\"noopener noreferrer nofollow\">App Store<\/a>.<\/p>\n<p>\u041a\u0430\u043a\u0438\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u043c\u043e\u0433\u0443\u0442 \u0432\u0441\u0442\u0440\u0435\u0442\u0438\u0442\u044c\u0441\u044f \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438? \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0442\u044c\u0441\u044f.<\/p>\n<h2>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430 View <\/h2>\n<p>\u0413\u043b\u0430\u0432\u043d\u0430\u044f \u0438 \u0441\u0430\u043c\u0430\u044f \u0431\u043e\u043b\u044c\u0448\u0430\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043d\u0430\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u0442 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u043f\u043e\u0447\u0442\u0438 \u043d\u0430 \u043b\u044e\u0431\u043e\u0439 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434. \u041c\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u043e \u043d\u0430 MVI, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u0431\u0443\u0434\u0443 \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u044d\u0442\u043e\u0439 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b. \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043e\u0431 MVI \u044f \u043f\u0438\u0441\u0430\u043b \u0432 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/512542\/\" rel=\"noopener noreferrer nofollow\">MVI \u0438 SwiftUI \u2013 \u043e\u0434\u043d\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435<\/a><\/p>\n<p>\u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u0434\u0435\u043b\u0430\u044e \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043e\u0442\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u0435:<\/p>\n<h4>@ObservedObject \u0438 @StateObject<\/h4>\n<p>\u0412 MVI \u0435\u0441\u0442\u044c \u043c\u043e\u0434\u0443\u043b\u044c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u0431\u0438\u0437\u043d\u0435\u0441 \u043b\u043e\u0433\u0438\u043a\u0443, \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f Intent. \u0423 View \u043d\u0430 Intent \u0435\u0441\u0442\u044c \u0441\u0441\u044b\u043b\u043a\u0430.<\/p>\n<pre><code class=\"swift\">struct ContentView: View {      @ObservedObject var intent: ContentIntent      var body: some View {         Text(\"Hello, world!\")     } }<\/code><\/pre>\n<p>@ObservableObject \u043d\u0443\u0436\u0435\u043d \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c \u0432\u0441\u0435, \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432 \u043a\u043b\u0430\u0441\u0441\u0435 \u0438 \u0441\u043e\u043e\u0431\u0449\u0430\u0442\u044c \u043e\u0431 \u044d\u0442\u043e\u043c View, \u0430 \u0442\u043e\u0442, \u0432 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c, \u043e\u043f\u0438\u0440\u0430\u044f\u0441\u044c \u043d\u0430 \u043d\u043e\u0432\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u043c\u0435\u043d\u044f\u0435\u0442 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 UI \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432.<\/p>\n<p>\u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u043a \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0435.<\/p>\n<p>View \u0432 SwiftUI \u043e\u0431\u043b\u0430\u0434\u0430\u0435\u0442 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044c\u044e \u2014 \u043a\u043e\u0433\u0434\u0430 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043f\u0435\u0440\u0435\u0440\u0438\u0441\u043e\u0432\u0430\u0442\u044c View, \u043e\u043d  \u043f\u0435\u0440\u0435\u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f, \u0432 \u0442\u0430\u043a\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 init \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e. \u041a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e, View \u043f\u0435\u0440\u0435\u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f, \u043a\u043e\u0433\u0434\u0430 \u0443 \u0434\u0440\u0443\u0433\u043e\u0439 View, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u0442\u043e\u0438\u0442 \u043f\u043e \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u0438 \u0432\u044b\u0448\u0435, \u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f \u0434\u0430\u043d\u043d\u044b\u0435.<\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u0440\u0438\u043c\u0435\u0440 \u043d\u0438\u0436\u0435, \u0433\u0434\u0435 \u043e\u0434\u043d\u0430 \u0438\u0437 View \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e \u043f\u0435\u0440\u0435\u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f.<\/p>\n<pre><code class=\"swift\">\/\/ MARK: - Screen ContentView struct ContentView: View {      @State var isNestScreenVisible = false     @State var seconds = \"0\"      var body: some View {         NavigationView {             VStack(spacing: 16) {                 Text(\"Seconds: \\(seconds)\")                 NavigationLink(\"Next screen\", destination: NextView(), isActive: $isNestScreenVisible)             }         }.onAppear {             Timer.scheduledTimer(withTimeInterval: 1, repeats: true) { timer in                 self.seconds = String(Int(Date().timeIntervalSince1970) % 60)             }         }     } }  \/\/ MARK: - Scren NextView struct NextView: View {      @ObservedObject var intent: NextIntent      init() {         intent = ContentIntent()          print(\"init NextView\")     }      var body: some View {         Text(\"Hello Weold!\")     } <\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u043e\u0442\u043a\u0440\u044b\u0442\u044c \u044d\u043a\u0440\u0430\u043d NextView, \u0442\u043e \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u0443 \u043d\u0435\u0433\u043e \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u043a\u0430\u0436\u0434\u0443\u044e \u0441\u0435\u043a\u0443\u043d\u0434\u0443. \u0412 \u043a\u043e\u043d\u0441\u043e\u043b\u0438 \u043c\u044b \u0443\u0432\u0438\u0434\u0438\u043c:<\/p>\n<pre><code class=\"bash\">init NextView init NextView init NextView init NextView init NextView init NextView init NextView init NextView init NextView<\/code><\/pre>\n<\/p>\n<p>\u041a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u043a\u043e\u0433\u0434\u0430 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f init, \u0432\u0441\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0432\u043d\u0443\u0442\u0440\u0438 View \u043f\u0435\u0440\u0435\u0441\u043e\u0437\u0434\u0430\u044e\u0442\u0441\u044f \u0438 \u043c\u043e\u0434\u0443\u043b\u044c, \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0449\u0438\u0439 \u0437\u0430 \u0431\u0438\u0437\u043d\u0435\u0441 \u043b\u043e\u0433\u0438\u043a\u0443 (\u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 Intent), \u0442\u0430\u043a\u0436\u0435 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u043d \u0437\u0430\u043d\u043e\u0432\u043e, \u0432\u0441\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u043d\u0435\u043c \u0441\u0431\u0440\u043e\u0441\u044f\u0442\u0441\u044f. \u0412 \u043b\u044e\u0431\u043e\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u044d\u043a\u0440\u0430\u043d \u043c\u043e\u0436\u0435\u0442 \u0432\u0435\u0440\u043d\u0443\u0442\u044c\u0441\u044f \u043a \u0441\u0432\u043e\u0435\u043c\u0443 \u043f\u0435\u0440\u0432\u043e\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u043c\u0443 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044e, \u0442.&nbsp;\u0435. \u043a \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044e \u043d\u0430 \u043c\u043e\u043c\u0435\u043d\u0442 \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u044f.<\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u044d\u0442\u043e\u0433\u043e \u043d\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u043b\u043e, @ObservedObject \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u043d\u0430 @StateObject \u0438 \u0442\u043e\u0433\u0434\u0430 Intent \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u0435\u0442 \u0437\u0430\u0432\u0438\u0441\u0435\u0442\u044c \u043e\u0442 \u0436\u0438\u0437\u043d\u0435\u043d\u043d\u043e\u0433\u043e \u0446\u0438\u043a\u043b\u0430 View.&nbsp;<\/p>\n<p>\u041a\u0430\u043a \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442?&nbsp;<\/p>\n<p>\u041a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u043a\u043e\u0433\u0434\u0430 View \u043f\u0435\u0440\u0435\u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f, \u0443 \u0432\u0441\u0435\u0445 \u043c\u043e\u0434\u0443\u043b\u0435\u0439 \u0432 \u043d\u0435\u043c \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 (\u0432 MVI \u044d\u0442\u043e Intent \u0438 Model, \u0432 MVVM \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 ViewModel).<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a Intent \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d, \u043e\u043d \u043f\u043e\u043c\u0435\u0449\u0430\u0435\u0442\u0441\u044f \u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 @StateObject; \u0435\u0441\u043b\u0438 \u0442\u0430\u043c \u0443\u0436\u0435 \u043b\u0435\u0436\u0438\u0442 \u043e\u0431\u044a\u0435\u043a\u0442 Intent, \u0442\u043e \u043d\u043e\u0432\u044b\u0439 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0439 Intent \u0443\u0434\u0430\u043b\u044f\u0435\u0442\u0441\u044f. @StateObject \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u0445\u043e\u0436 \u043d\u0430 Singleton, \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u043d \u0443\u0434\u0430\u043b\u044f\u0435\u0442\u0441\u044f \u0438\u0437 \u043f\u0430\u043c\u044f\u0442\u0438.<\/p>\n<blockquote>\n<p><em>\u0423\u0447\u0438\u0442\u044b\u0432\u0430\u044f, \u0447\u0442\u043e \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u0443 Intent \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e, \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u043e\u043d \u0431\u0443\u0434\u0435\u0442 @StateObject, \u0432 init \u043d\u0435 \u0441\u0442\u043e\u0438\u0442 \u043f\u0438\u0441\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0438 \u043b\u044e\u0431\u0443\u044e \u0434\u0440\u0443\u0433\u0443\u044e \u043b\u043e\u0433\u0438\u043a\u0443 \u043a\u0440\u043e\u043c\u0435 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0432\u043d\u0443\u0442\u0440\u0438 Intent. <\/em><\/p>\n<\/p>\n<p><em>@StateObject \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u0441 \u0432\u0435\u0440\u0441\u0438\u0438 iOS 14.<\/em><\/p>\n<\/blockquote>\n<h4>\u041c\u043e\u0436\u043d\u043e \u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c @ObservedObject, \u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0435\u0433\u043e Singleton?<\/h4>\n<p>\u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043f\u043e\u0434\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0442\u044c \u0443\u0436\u0435 \u0433\u043e\u0442\u043e\u0432\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442.<\/p>\n<pre><code class=\"swift\">struct ContentView: View {      @ObservedObject var intent: ContentInten      init() {         self.intent = ContentInten.shared         let model = ContentModel()         self.intent.update(model: model)     }          var body: some View {         Text(\"Hello, world!\")     } <\/code><\/pre>\n<p>\u041e\u0434\u043d\u0430 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0437\u0430\u043a\u0440\u043e\u0435\u0442\u0441\u044f, \u043d\u043e \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u0443\u0442 \u0434\u0440\u0443\u0433\u0438\u0435:<\/p>\n<ol>\n<li>\n<p>\u041f\u0440\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 Intent \u043f\u0440\u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0431\u0443\u0434\u0443\u0442 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0442\u044c \u0432\u043e\u043f\u0440\u043e\u0441\u044b (\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u043b\u0438 \u0441\u0435\u0439\u0447\u0430\u0441 \u0434\u0430\u043d\u043d\u044b\u0435, \u0435\u0441\u043b\u0438 \u043e\u043d\u0438 \u0443\u0436\u0435 \u0435\u0441\u0442\u044c, \u043d\u0443\u0436\u043d\u043e \u043b\u0438 \u0438\u0445 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0438 \u0442.&nbsp;\u0434.)<\/p>\n<\/li>\n<li>\n<p>Singleton \u043c\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u043c \u0443\u043d\u0438\u0447\u0442\u043e\u0436\u0438\u0442\u044c \u0438 \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u0434\u0435\u0440\u0436\u0430\u0442\u044c\u0441\u044f \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 \u0432\u0441\u044e \u0441\u0435\u0441\u0441\u0438\u044e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f&nbsp;<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u0432\u0442\u043e\u0440\u043e\u0433\u043e, \u0442\u0440\u0435\u0442\u044c\u0435\u0433\u043e \u0438 \u0434\u0440\u0443\u0433\u0438\u0445 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u044d\u043a\u0440\u0430\u043d\u043e\u0432 \u0443 \u043d\u0430\u0441 \u0431\u0443\u0434\u0435\u0442 \u043e\u0434\u0438\u043d Singleton \u043d\u0430 \u0432\u0441\u0435 \u044d\u0442\u0438 \u044d\u043a\u0440\u0430\u043d\u044b.&nbsp;<\/p>\n<\/li>\n<\/ol>\n<p>SwiftUI \u0432 iOS 14 \u0441\u0438\u043b\u044c\u043d\u043e \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0431\u043e\u0440\u043e\u0442\u044c\u0441\u044f \u0441 \u044d\u0442\u0438\u043c\u0438 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430\u043c\u0438 \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439, \u0435\u0441\u0442\u044c \u0441\u043c\u044b\u0441\u043b \u0434\u0435\u043b\u0430\u0442\u044c \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u0438 iOS 14 \u0434\u043b\u044f \u044d\u043a\u0440\u0430\u043d\u043e\u0432 SwiftUI.<\/p>\n<h4>\u041e\u0431\u044a\u0435\u043a\u0442 @StateObject \u043d\u0435\u043b\u044c\u0437\u044f \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u043d\u0443\u0442\u0440\u0438 init View<\/h4>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0415\u0449\u0435 \u043e\u0434\u043d\u0430 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044c. Intent \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d \u0432\u043d\u0435 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430 View. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u0432 \u043a\u043e\u0442\u043e\u0440\u0443\u044e, \u0435\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u043e, \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435.<\/p>\n<pre><code class=\"swift\">struct ContentView: View {      @StateObject var intent: ContentInten      var body: some View {         Text(\"Hello, world!\")     }      static func build() -&gt; some View {         let model = ContentModel()         let intent = ContentInten(model: model)         return ContentView(intent: intent)     } <\/code><\/pre>\n<\/p>\n<p>\u0412 \u043e\u0431\u0449\u0435\u043c, \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u043c\u043d\u043e\u0433\u043e \u043d\u0435\u0443\u0434\u043e\u0431\u0441\u0442\u0432 \u0438 \u043d\u0430\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u0438\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u043d\u0430 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0443 \u0434\u043b\u044f iOS 13.<\/p>\n<h2>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 onAppear \u0438 onDisappear<\/h2>\n<p>\u041c\u044b \u043d\u0435 \u0437\u043d\u0430\u0435\u043c, \u043a\u043e\u0433\u0434\u0430 View \u0443\u0434\u0430\u043b\u0435\u043d \u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0435\u0433\u043e \u043d\u0435 \u0432\u0438\u0434\u0438\u0442, \u0438\u043b\u0438 \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442, \u043a\u043e\u0433\u0434\u0430 View \u0432\u043f\u0435\u0440\u0432\u044b\u0435 \u043f\u043e\u043a\u0430\u0437\u0430\u043d. \u0415\u0441\u0442\u044c \u043c\u043d\u0435\u043d\u0438\u0435 \u0447\u0442\u043e, \u0447\u0442\u043e onAppear \u0438 onDisappear \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u043e\u0434\u0438\u043d \u0440\u0430\u0437, \u043a\u043e\u0433\u0434\u0430 \u044d\u043a\u0440\u0430\u043d \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u0438 \u043a\u043e\u0433\u0434\u0430 \u043e\u043d \u0443\u0434\u0430\u043b\u044f\u0435\u0442\u0441\u044f. \u042d\u0442\u043e \u043d\u0435 \u0442\u0430\u043a. \u0418 \u0442\u043e\u0442 \u0438 \u0434\u0440\u0443\u0433\u043e\u0439 \u043c\u0435\u0442\u043e\u0434 \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0437\u0432\u0430\u0442\u044c\u0441\u044f \u0431\u043e\u043b\u0435\u0435 \u043e\u0434\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u0430 \u0443 \u043e\u0434\u043d\u043e\u0433\u043e \u044d\u043a\u0440\u0430\u043d\u0430.&nbsp;<\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u0440\u0438\u043c\u0435\u0440<\/p>\n<pre><code class=\"swift\">struct ContentView: View {      @State var isVisibleHomeScreen = false      var body: some View {         NavigationView {             VStack {                 Text(\"Hello, world!\")                  NavigationLink(destination: Text(\"Screen Home\"),                                isActive: $isVisibleHomeScreen,                                label: { Text(\"Open screen\") })             }.onAppear {                 print(\"onAppear was called\")             }.onDisappear {                 print(\"onDisappear was called\")             }         }     } <\/code><\/pre>\n<p>\u041f\u0440\u0438 \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u0438 \u0438 \u0437\u0430\u043a\u0440\u044b\u0442\u0438\u0438 \u044d\u043a\u0440\u0430\u043d\u0430 <u>\u0432\u043d\u0443\u0442\u0440\u0438 NavigationView<\/u> \u044d\u0442\u0438 \u043c\u0435\u0442\u043e\u0434\u044b \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u044e\u0442 \u0431\u043e\u043b\u0435\u0435 \u043e\u0434\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u0430. \u0412 \u043a\u043e\u043d\u0441\u043e\u043b\u0438 \u043c\u044b \u0443\u0432\u0438\u0434\u0438\u043c:<\/p>\n<pre><code class=\"bash\">onDisappear was called onAppear was called<\/code><\/pre>\n<\/p>\n<p>\u041a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e, NavigationView \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0443 \u043e\u0434\u043d\u043e\u0433\u043e \u044d\u043a\u0440\u0430\u043d\u0430, \u043f\u0435\u0440\u0432\u043e\u0433\u043e, \u0430 \u0443 \u0432\u0441\u0435\u0445 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0443\u0436\u0435 \u043d\u0435\u0442. onAppear \u0438 onDisappear \u0431\u0443\u0434\u0443\u0442 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u044d\u043a\u0440\u0430\u043d\u0430\u0445 \u0431\u043e\u043b\u044c\u0448\u0435 \u043e\u0434\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u0430. \u042d\u0442\u043e \u043d\u0430\u0434\u043e \u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0432 \u0433\u043e\u043b\u043e\u0432\u0435 \u043f\u0440\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u0430\u043a\u0438\u0445-\u043b\u0438\u0431\u043e \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u043d\u044b\u0445 \u0440\u0435\u0448\u0435\u043d\u0438\u0439.<\/p>\n<h2>\u041d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u044f<\/h2>\n<p>\u041a\u0430\u043a \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u044e \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u0441\u043e SwiftUI? \u042d\u0442\u043e\u0442 \u0432\u043e\u043f\u0440\u043e\u0441 \u0441\u0442\u043e\u0438\u0442 \u043e\u0441\u043e\u0431\u043e \u043e\u0441\u0442\u0440\u043e, \u0442\u0430\u043a \u043a\u0430\u043a \u043d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u044f \u0442\u0443\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043f\u043e \u0434\u0440\u0443\u0433\u0438\u043c \u043f\u0440\u0430\u0432\u0438\u043b\u0430\u043c, \u0438 \u0432\u0435\u0441\u044c \u043d\u0430\u043a\u043e\u043f\u043b\u0435\u043d\u043d\u044b\u0439 \u043e\u043f\u044b\u0442 \u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u0430 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 UIKit \u0442\u0443\u0442 \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u041c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u043d\u0435\u043c\u0430\u043b\u043e \u0441\u0442\u0430\u0442\u0435\u0439 \u0438 \u0432\u0438\u0434\u0435\u043e, \u043f\u043e\u0441\u0432\u044f\u0449\u0435\u043d\u043d\u044b\u0445 \u0442\u0435\u043c\u0435 \u043d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u0438 \u0432 SwiftUI. \u0412\u0441\u0435, \u0447\u0442\u043e \u044f \u0432\u0438\u0434\u0435\u043b, \u0438\u043b\u0438 \u043d\u0435\u0443\u0434\u043e\u0431\u043d\u043e, \u0438\u043b\u0438 \u0433\u0440\u043e\u043c\u043e\u0437\u0434\u043a\u043e. \u042f \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u0441\u0432\u043e\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442, \u0447\u0442\u043e\u0431\u044b \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u044b \u0434\u0435\u043b\u0430\u043b\u0438\u0441\u044c \u0440\u043e\u0432\u043d\u043e \u0442\u0430\u043a, \u043a\u0430\u043a \u043d\u0430\u043c \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u043b\u0438 \u043d\u0430 WWDC. \u042d\u0442\u043e \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u043d\u0435\u0441\u043b\u043e\u0436\u043d\u043e, \u0432\u0441\u044e \u043b\u043e\u0433\u0438\u043a\u0443 \u043d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u0438 \u043d\u0443\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0432\u044b\u043d\u0435\u0441\u0442\u0438 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 &#171;some View&#187;.&nbsp;<\/p>\n<p>\u0412\u043e \u0432\u0440\u0435\u043c\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0442 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0440\u043e\u0443\u0442\u0435\u0440\u0430 \u043f\u043e\u043a\u0430\u0437\u0430\u043b \u0441\u0435\u0431\u044f \u043e\u0447\u0435\u043d\u044c \u0445\u043e\u0440\u043e\u0448\u043e, \u0434\u0430\u0436\u0435 \u043b\u0443\u0447\u0448\u0435, \u0447\u0435\u043c MVI. \u0422\u0430\u043a \u043a\u0430\u043a \u044d\u0442\u043e \u0431\u043e\u043b\u044c\u0448\u0430\u044f \u0442\u0435\u043c\u0430, \u043f\u043e\u0434 \u0441\u043f\u043e\u043b\u0435\u0440\u043e\u043c \u044f \u043e\u0441\u0442\u0430\u0432\u043b\u044e \u043f\u0440\u0438\u043c\u0435\u0440, \u0430 \u0441\u0430\u043c \u043f\u043e\u0434\u0445\u043e\u0434, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u043e\u043f\u0438\u0448\u0443 \u0432 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435.<\/p>\n<details class=\"spoiler\">\n<summary>Router<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"swift\">\/\/  ContentRouter.swift \/\/ \/\/  Copyright \u00a9 2020 Vyacheslav Ansimov. All rights reserved. \/\/ import SwiftUI import Combine  \/\/ MARK: - Realization struct ContentRouter: View {      enum ScreenType {         case sheetScreen(value: String)         case navigationScreen(value: String)         case exit     }      private class ScreenTypeHolder: ObservableObject {         @Published var type: ScreenType?     }      \/\/ API     let screen: PassthroughSubject&lt;ScreenType, Never&gt;      \/\/ private     @Environment(\\.presentationMode) private var presentationMode     @StateObject private var screenType = ScreenTypeHolder()      \/\/ Life cycle     var body: some View {         displayView().onReceive(screen) { self.screenType.type = $0 }     }      private func displayView() -&gt; some View {         let isVisible = Binding&lt;Bool&gt;(get: { screenType.type != nil },                                       set: { if !$0 { screenType.type = nil } })         \/\/ Screens         switch screenType.type {         case .sheetScreen(let value):             return AnyView(                 Spacer().sheet(isPresented: isVisible) {                     Text(value)                 }             )          case .navigationScreen(let value):             return AnyView (                 NavigationLink(\"\", destination: Text(value), isActive: isVisible)             )          case .exit:             presentationMode.wrappedValue.dismiss()             return AnyView(EmptyView())          case .none:             return AnyView(EmptyView())         }     } }  \/\/ MARK: - Example struct ContentRouter_Previews: PreviewProvider {     static let routeSubject = PassthroughSubject&lt;ContentRouter.ScreenType, Never&gt;()      static var previews: some View {         NavigationView {             VStack {                 Button(action: {                     self.routeSubject.send(.sheetScreen(value: \"Hello World!\"))                 }, label: { Text(\"Display Sheet Screen\") })                  Button(action: {                     self.routeSubject.send(.navigationScreen(value: \"Hello World!\"))                 }, label: { Text(\"Display NavigationLink Screen\") })             }             .overlay(ContentRouter(screen: routeSubject))         }     } }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<h2>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u043f\u0440\u043e\u043a\u0441\u0438<\/h2>\n<p>Property wrapper (State, Binding, ObservedObject \u0438 \u0434\u0440.) \u0434\u0430\u044e\u0442 SwiftUI \u0440\u0435\u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u0438 \u0438 \u0434\u0435\u043b\u0430\u0435\u0442 \u0443\u0434\u043e\u0431\u043d\u044b\u043c \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 UI.<\/p>\n<p>\u0410 \u0435\u0441\u043b\u0438 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0432\u044b\u043d\u0435\u0441\u0442\u0438 \u044d\u0442\u0438 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441. \u0422\u043e\u0433\u0434\u0430 \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u043a\u043b\u0430\u0441\u0441, \u043f\u043e\u0434\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u0434 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b ObservableObject \u0438 \u043f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u043e View<\/p>\n<pre><code class=\"swift\">\/\/ MARK: Model class ContentModel: ObservableObject {     @Publised var title = \"Hello World!\" }  \/\/ MARK:<\/code><\/pre>\n<\/div>\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-315390","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/315390","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=315390"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/315390\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=315390"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=315390"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=315390"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}