{"id":301344,"date":"2020-04-06T09:00:23","date_gmt":"2020-04-06T09:00:23","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=301344"},"modified":"-0001-11-30T00:00:00","modified_gmt":"2020-04-06T09:00:23","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=301344","title":{"rendered":"\u0418\u0437 \u043e\u0448\u0438\u0431\u043a\u0438 \u0432 \u0430\u043b\u0435\u0440\u0442 \u0441 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f\u043c\u0438"},"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\/company\/manychat\/blog\/495346\/\">\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440! \u0414\u043b\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u043e\u0431 \u043e\u0448\u0438\u0431\u043a\u0435 \u0447\u0430\u0441\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u044f\u0442 \u043a\u0430\u043a \u00ab\u0427\u0442\u043e-\u0442\u043e \u043d\u0435 \u0442\u0430\u043a, \u0410\u0410\u0410\u0410!\u00bb. \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u0435\u043c\u0443 \u0431\u044b \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0432\u043c\u0435\u0441\u0442\u043e \u043e\u0448\u0438\u0431\u043e\u043a \u0432\u0438\u0434\u0435\u0442\u044c \u0432\u043e\u043b\u0448\u0435\u0431\u043d\u0443\u044e \u043e\u0448\u0438\u0431\u043a\u0443 \u00ab\u041f\u043e\u0447\u0438\u043d\u0438\u0442\u044c \u0432\u0441\u0435\u00bb. \u041d\u0443 \u0438\u043b\u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439. \u041c\u044b \u043d\u0430\u0447\u0430\u043b\u0438 \u0430\u043a\u0442\u0438\u0432\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0441\u0435\u0431\u0435 \u0442\u0430\u043a\u0438\u0435, \u0438 \u044f \u0445\u043e\u0447\u0443 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c \u043f\u0440\u043e \u0442\u043e, \u043a\u0430\u043a \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c. <\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/6q\/cf\/s3\/6qcfs3uiu0o9ajdlcfi8frjb5pg.jpeg\"><\/p>\n<p>  \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044e\u0441\u044c \u2014 \u043c\u0435\u043d\u044f \u0437\u043e\u0432\u0443\u0442 \u0410\u043b\u0435\u043a\u0441\u0430\u043d\u0434\u0440, \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0435 \u0448\u0435\u0441\u0442\u044c \u043b\u0435\u0442 \u044f \u043f\u043e\u0441\u0432\u044f\u0442\u0438\u043b iOS-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435. \u0421\u0435\u0439\u0447\u0430\u0441 \u043e\u0442\u0432\u0435\u0447\u0430\u044e \u0437\u0430 \u043c\u043e\u0431\u0438\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 ManyChat \u0438 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0431\u0443\u0434\u0443 \u0440\u0435\u0448\u0430\u0442\u044c \u043d\u0430 \u0435\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0435. <\/p>\n<p>  \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u0440\u0430\u0437\u0443 \u0441\u0444\u043e\u0440\u043c\u0443\u043b\u0438\u0440\u0443\u0435\u043c, \u0447\u0442\u043e \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0434\u0435\u043b\u0430\u0442\u044c:<\/p>\n<ul>\n<li>\u0414\u043e\u0431\u0430\u0432\u0438\u043c \u0442\u0438\u043f\u0443 Error \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438<\/li>\n<li>\u041f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u043c \u043e\u0448\u0438\u0431\u043a\u0438 \u0432 \u043f\u043e\u043d\u044f\u0442\u043d\u044b\u0435 \u0434\u043b\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0430\u043b\u0435\u0440\u0442\u044b<\/li>\n<li>\u0412\u044b\u0432\u0435\u0434\u0435\u043c \u0432 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0435 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0438\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u0438\u0445 \u043d\u0430\u0436\u0430\u0442\u0438\u044f<\/li>\n<\/ul>\n<p>  \u0418 \u0432\u0441\u0435 \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u043d\u0430 Swift:)<\/p>\n<p>  <a name=\"habracut\"><\/a>\u0411\u0443\u0434\u0435\u043c \u0440\u0435\u0448\u0430\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u0441 \u043f\u0440\u0438\u043c\u0435\u0440\u0430. \u0421\u0435\u0440\u0432\u0435\u0440 \u0432\u0435\u0440\u043d\u0443\u043b \u043e\u0448\u0438\u0431\u043a\u0443 \u0441 \u043a\u043e\u0434\u043e\u043c 500 \u0432\u043c\u0435\u0441\u0442\u043e \u043e\u0436\u0438\u0434\u0430\u0435\u043c\u044b\u0445 200. \u0427\u0442\u043e \u0441\u0442\u043e\u0438\u0442 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0443? \u041a\u0430\u043a \u043c\u0438\u043d\u0438\u043c\u0443\u043c, \u0441 \u0433\u0440\u0443\u0441\u0442\u044c\u044e \u0441\u043e\u043e\u0431\u0449\u0438\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e \u2014 \u043e\u0436\u0438\u0434\u0430\u0435\u043c\u044b\u0439 \u043f\u043e\u0441\u0442 \u0441 \u043a\u043e\u0442\u0438\u043a\u0430\u043c \u043d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c. \u0412 Apple \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u043c \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u043e\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0430\u043b\u0435\u0440\u0442, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e:<\/p>\n<pre><code class=\"swift\">final class FeedViewController: UIViewController {   \/\/ \u0413\u0434\u0435-\u0442\u043e \u0432 \u0433\u043b\u0443\u0431\u0438\u043d\u0435 \u043a\u043e\u0434\u0430  \tfunc handleFeedResponse(...) { \t\/\/\/ \u0413\u0434\u0435-\u0442\u043e \u0432\u043d\u0443\u0442\u0440\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043e\u0442\u0432\u0435\u0442\u0430 \tif let error = error { \t\tlet alertVC = UIAlertController( \t\t\ttitle: &quot;Error&quot;, \t\t\tmessage: &quot;Error connecting to the server&quot;, \t\t\tpreferredStyle: .alert) \t\tlet action = UIAlertAction(title: &quot;OK&quot;, style: .default, handler: nil) \t\talertVC.addAction(action) \t\tself.present(alertVC, animated: true, completion: nil) \t} }<\/code><\/pre>\n<p>  P.S. \u0414\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u044b \u0431\u043e\u043b\u044c\u0448\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u043a\u043e\u0434\u0430 \u0431\u0443\u0434\u0435\u0442 \u0432 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0435\u0440\u0435. \u0412\u044b \u0432\u043e\u043b\u044c\u043d\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u0435 \u0436\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u044b \u0432 \u0432\u0430\u0448\u0435\u0439 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0435. \u041a\u043e\u0434 \u0441\u0442\u0430\u0442\u044c\u0438 \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u0432 <a href=\"https:\/\/github.com\/aleksiosdev\/RecoverableError.git\">\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438<\/a>, \u0432 \u043a\u043e\u043d\u0446\u0435 \u0441\u0442\u0430\u0442\u044c\u0438 \u044d\u0442\u0430 \u0441\u0441\u044b\u043b\u043a\u0430 \u0442\u043e\u0436\u0435 \u0431\u0443\u0434\u0435\u0442.<\/p>\n<p>  \u041f\u043e\u043b\u0443\u0447\u0438\u043c \u0432\u043e\u0442 \u0442\u0430\u043a\u0443\u044e \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0443:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/9o\/ra\/ee\/9oraeel1k7noyxjplcumz1b56jy.png\"><\/p>\n<p>  \u0422\u0435\u043e\u0440\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0437\u0430\u0434\u0430\u0447\u0443 \u043c\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u043b\u0438. \u041d\u043e \u0441\u0440\u0430\u0437\u0443 \u0431\u0440\u043e\u0441\u0430\u0435\u0442\u0441\u044f \u0432 \u0433\u043b\u0430\u0437\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u0435\u0449\u0435\u0439:<\/p>\n<ul>\n<li>\u041c\u044b \u043d\u0435 \u0434\u0430\u043b\u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043a\u0430\u043a-\u0442\u043e \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u0438\u0437 \u043e\u0448\u0438\u0431\u043e\u0447\u043d\u043e\u0433\u043e \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u044f \u0432 \u0443\u0441\u043f\u0435\u0448\u043d\u044b\u0439. \u041e\u041a \u0432 \u0442\u0435\u043a\u0443\u0449\u0435\u043c \u043a\u0435\u0439\u0441\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043a\u0440\u043e\u0435\u0442 \u0430\u043b\u0435\u0440\u0442 \u2014 \u0438 \u044d\u0442\u043e \u043d\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435<\/li>\n<li>\u0421 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f UX&#8217;\u0430 \u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0433\u043e \u043e\u043f\u044b\u0442\u0430 \u0442\u0435\u043a\u0441\u0442 \u043d\u0443\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u043e\u043d\u044f\u0442\u043d\u0435\u0439, \u043d\u0435\u0439\u0442\u0440\u0430\u043b\u044c\u043d\u0435\u0439. \u0427\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043d\u0435 \u043f\u0443\u0433\u0430\u043b\u0441\u044f \u0438 \u043d\u0435 \u0431\u0435\u0436\u0430\u043b \u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043e\u0434\u043d\u0443 \u0437\u0432\u0435\u0437\u0434\u0443 \u0432 AppStore \u0432\u0430\u0448\u0435\u043c\u0443 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044e. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u044b\u0439 \u0442\u0435\u043a\u0441\u0442 \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u043b\u0441\u044f \u0431\u044b \u043d\u0430\u043c \u043f\u0440\u0438 \u0434\u0435\u0431\u0430\u0433\u0435<\/li>\n<li>\u0418, \u0431\u0443\u0434\u0435\u043c \u0447\u0435\u0441\u0442\u043d\u044b \u2014 \u0430\u043b\u0435\u0440\u0442\u044b \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0443\u0441\u0442\u0430\u0440\u0435\u043b\u0438 \u043a\u0430\u043a \u0440\u0435\u0448\u0435\u043d\u0438\u0435 (\u0432\u0441\u0435 \u0447\u0430\u0449\u0435 \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u0445 \u043f\u043e\u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043b\u0438\u0431\u043e \u044d\u043a\u0440\u0430\u043d\u044b-\u0437\u0430\u0433\u043b\u0443\u0448\u043a\u0438, \u043b\u0438\u0431\u043e \u0442\u043e\u0441\u0442\u044b). \u041d\u043e \u044d\u0442\u043e \u0443\u0436\u0435 \u0432\u043e\u043f\u0440\u043e\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u0442\u043e\u0438\u0442 \u043e\u0431\u0441\u0443\u0434\u0438\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u0441 \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439<\/li>\n<\/ul>\n<p>  \u0421\u043e\u0433\u043b\u0430\u0441\u0438\u0442\u0435\u0441\u044c, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0439 \u043d\u0438\u0436\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0441\u0438\u043c\u043f\u0430\u0442\u0438\u0428\u043d\u0435\u0435<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/jv\/0z\/oz\/jv0zozzv3foowtocsqkk_pjdifo.png\"><\/p>\n<p>  \u041a\u0430\u043a\u043e\u0439 \u0431\u044b \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0432\u044b \u043d\u0438 \u0432\u044b\u0431\u0440\u0430\u043b\u0438, \u043f\u043e\u0434 \u043b\u044e\u0431\u043e\u0439 \u0438\u0437 \u043d\u0438\u0445 \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0434\u0443\u043c\u0430\u0442\u044c \u0442\u0430\u043a\u043e\u0439 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u043f\u043e\u043a\u0430\u0437\u0430 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u043e\u0442\u043b\u0438\u0447\u043d\u043e \u043f\u0440\u0438 \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u043e\u0432\u0435\u043d\u0438\u0438 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u043e\u0448\u0438\u0431\u043a\u0438, \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0438\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e \u044f\u0441\u043d\u044b\u0439 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0439 \u0434\u043b\u044f \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0439 \u0440\u0430\u0431\u043e\u0442\u044b \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u0438 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u0438\u0442 \u043d\u0430\u0431\u043e\u0440 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0435:   <\/p>\n<ul>\n<li>\u0414\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0440\u0430\u0441\u0448\u0438\u0440\u044f\u0435\u043c\u044b\u043c. \u0412\u0441\u0435 \u043c\u044b \u0437\u043d\u0430\u0435\u043c \u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u0434\u0438\u0437\u0430\u0439\u043d\u0443 \u0438\u0437\u043c\u0435\u043d\u0447\u0438\u0432\u043e\u0441\u0442\u0438. \u041d\u0430\u0448 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0433\u043e\u0442\u043e\u0432 \u043a\u043e \u0432\u0441\u0435\u043c\u0443<\/li>\n<li>\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043a \u043e\u0431\u044a\u0435\u043a\u0442\u0443 (\u0438 \u0443\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f) \u0432 \u043f\u0430\u0440\u0443 \u0441\u0442\u0440\u043e\u0447\u0435\u043a \u043a\u043e\u0434\u0430<\/li>\n<li>\u0425\u043e\u0440\u043e\u0448\u043e \u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u0442\u0441\u044f<\/li>\n<\/ul>\n<p>  \u041d\u043e \u043f\u0435\u0440\u0435\u0434 \u044d\u0442\u0438\u043c \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043e\u043a\u0443\u043d\u0451\u043c\u0441\u044f \u0432 \u0442\u0435\u043e\u0440\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043c\u0438\u043d\u0438\u043c\u0443\u043c \u043f\u043e \u043e\u0448\u0438\u0431\u043a\u0430\u043c \u0432 Swift. <\/p>\n<h3>Error \u0432 Swift<\/h3>\n<p>  \u042d\u0442\u043e\u0442 \u043f\u0430\u0440\u0430\u0433\u0440\u0430\u0444 \u2014 \u0432\u0435\u0440\u0445\u043d\u0435\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u044b\u0439 \u043e\u0431\u0437\u043e\u0440 \u043e\u0448\u0438\u0431\u043e\u043a \u0432 \u0446\u0435\u043b\u043e\u043c. \u0415\u0441\u043b\u0438 \u0432\u044b \u0443\u0436\u0435 \u0430\u043a\u0442\u0438\u0432\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435 \u0441\u0432\u043e\u0438 \u043e\u0448\u0438\u0431\u043a\u0438 \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438, \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u043c\u0435\u043b\u043e \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442\u044c \u043a \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c\u0443 \u043f\u0430\u0440\u0430\u0433\u0440\u0430\u0444\u0443. <\/p>\n<p>  \u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u043e\u0448\u0438\u0431\u043a\u0430? \u041d\u0435\u043a\u043e\u0435 \u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0438\u043b\u0438 \u043d\u0435\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442. \u0427\u0430\u0441\u0442\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0435 \u043e\u0448\u0438\u0431\u043a\u0438 \u0438 \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0438\u0445 \u0432 \u043a\u043e\u0434\u0435.<\/p>\n<p>  \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0441\u043b\u0443\u0447\u0430\u044f Apple \u0434\u0430\u044e\u0442 \u043d\u0430\u043c \u0442\u0438\u043f Error. \u0415\u0441\u043b\u0438 \u043c\u044b \u043e\u0442\u043a\u0440\u043e\u0435\u043c \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e Apple, \u0442\u043e Error \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0432\u043e\u0442 \u0442\u0430\u043a (\u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e \u0434\u043b\u044f Swift 5.1):<\/p>\n<pre><code class=\"swift\">public protocol Error { }<\/code><\/pre>\n<p>  \u041f\u0440\u043e\u0441\u0442\u043e \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b \u0431\u0435\u0437 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u0439. \u0414\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u043b\u044e\u0431\u0435\u0437\u043d\u043e \u043f\u043e\u044f\u0441\u043d\u044f\u0435\u0442 \u2014 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043b\u044e\u0431\u043e\u043c\u0443 \u0442\u0438\u043f\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043e\u0448\u0438\u0431\u043e\u043a Swift. \u0421 \u0442\u0430\u043a\u0438\u043c \u0449\u0430\u0434\u044f\u0449\u0438\u043c \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u043e\u043c \u043d\u0430\u043c \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0441\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c.<\/p>\n<p>  \u0412 \u0433\u043e\u043b\u043e\u0432\u0443 \u0441\u0440\u0430\u0437\u0443 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u043c\u044b\u0441\u043b\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c enum: \u043e\u0448\u0438\u0431\u043e\u043a \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0435 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e, \u0443 \u043d\u0438\u0445 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043a\u0430\u043a\u0438\u0435 \u0442\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b. \u0427\u0442\u043e \u0438 \u0434\u0435\u043b\u0430\u044e\u0442 Apple. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e DecodingError:<\/p>\n<pre><code class=\"swift\">public enum DecodingError : Error {              \/\/\/ \u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430, \u0445\u0440\u0430\u043d\u044f\u0449\u0430\u044f \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e\u0431 \u043e\u0448\u0438\u0431\u043a\u0435.      \t\/\/\/ \u041e\u0442\u043b\u0438\u0447\u043d\u0430\u044f \u0438\u0434\u0435\u044f, \u0441\u0442\u043e\u0438\u0442 \u0432\u0437\u044f\u0442\u044c \u043d\u0430 \u0437\u0430\u043c\u0435\u0442\u043a\u0443         public struct Context {          \t    \/\/\/ \u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043f\u0440\u0438\u0447\u0438\u043d \u043e\u0448\u0438\u0431\u043a\u0438             public let codingPath: [CodingKey]             public let debugDescription: String          \t    \/\/\/ \u041e\u0448\u0438\u0431\u043a\u0430, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u0430\u044f \u0441 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u043e\u0448\u0438\u0431\u043a\u043e\u0439.              \/\/\/ \u041c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u0447\u0435\u0439\u043d\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043e\u0448\u0438\u0431\u043e\u043a. \u0422\u043e\u0436\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0430\u044f \u0438\u0434\u0435\u044f             public let underlyingError: Error?                  public init(codingPath: [CodingKey], debugDescription: String, underlyingError: Error? = nil)         }          \t\/\/\/ N \u043a\u0435\u0439\u0441\u043e\u0432 \u0434\u043b\u044f \u043f\u0440\u0438\u0447\u0438\u043d \u043e\u0448\u0438\u0431\u043a\u0438         case typeMismatch(Any.Type, DecodingError.Context)         case valueNotFound(Any.Type, DecodingError.Context)          ...<\/code><\/pre>\n<p>  \u0412\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u043b\u0443\u0447\u0448\u0438\u043c\u0438 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0430\u043c\u0438 Apple. \u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043c \u0433\u0440\u0443\u043f\u043f\u0443 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0445 \u043e\u0448\u0438\u0431\u043e\u043a \u0441\u0435\u0442\u0438 \u0432 \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u043d\u043e\u043c \u0432\u0438\u0434\u0435: <\/p>\n<pre><code class=\"swift\">enum NetworkError: Error {        \/\/ \u041b\u044e\u0431\u043e\u0439 500 \u043a\u043e\u0434 \tcase serverError         \/\/ \u041e\u0442\u0432\u0435\u0442 \u043d\u0435 \u0442\u0430\u043a\u043e\u0439, \u043a\u0430\u043a \u043c\u044b \u043e\u0436\u0438\u0434\u0430\u0435\u043c \tcase responseError         \/\/ \u041e\u0442\u0432\u0435\u0442\u0430 \u043d\u0435\u0442, \u043e\u0442\u0432\u0430\u043b\u0438\u043b\u0438\u0441\u044c \u043f\u043e \u0442\u0430\u0439\u043c\u0430\u0443\u0442\u0443, \u043e\u0442\u0441\u0443\u0441\u0442\u0432\u0443\u0435\u0442 \u0441\u0435\u0442\u044c \tcase internetError }<\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c, \u0432 \u043b\u044e\u0431\u043e\u043c \u043c\u0435\u0441\u0442\u0435 \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0433\u0434\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043e\u0448\u0438\u0431\u043a\u0430, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0448 Network.Error. <\/p>\n<p>  \u041a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u043e\u0448\u0438\u0431\u043a\u0430\u043c\u0438? \u0415\u0441\u0442\u044c \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c do catch. \u0415\u0441\u043b\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043c\u043e\u0436\u0435\u0442 \u0431\u0440\u043e\u0441\u0438\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0443, \u0442\u043e \u043e\u043d\u0430 \u043f\u043e\u043c\u0435\u0447\u0430\u0435\u0442\u0441\u044f \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u043c \u0441\u043b\u043e\u0432\u043e\u043c throws. \u0422\u0435\u043f\u0435\u0440\u044c \u043a\u0430\u0436\u0434\u044b\u0439 \u0435\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043e\u0431\u044f\u0437\u0430\u043d \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c\u0441\u044f \u043a \u043d\u0435\u0439 \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044e do catch. \u041f\u0440\u0438 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0438 \u043e\u0448\u0438\u0431\u043a\u0438 \u043c\u044b \u043f\u043e\u043f\u0430\u0434\u0435\u043c \u0432 \u0431\u043b\u043e\u043a do, \u0441 \u043e\u0448\u0438\u0431\u043a\u043e\u0439 \u2014 \u0432 \u0431\u043b\u043e\u043a catch. \u0424\u0443\u043d\u043a\u0446\u0438\u0439, \u043f\u0440\u0438\u0432\u043e\u0434\u044f\u0449\u0438\u0445 \u043a \u043e\u0448\u0438\u0431\u043a\u0435, \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0443\u0433\u043e\u0434\u043d\u043e \u0432 \u0431\u043b\u043e\u043a\u0435 do. \u0415\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u043c\u0438\u043d\u0443\u0441 \u2014 \u043c\u044b \u0432 catch \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u043e\u0448\u0438\u0431\u043a\u0443 \u0442\u0438\u043f\u0430 Error. \u041f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u0441\u043a\u0430\u0441\u0442\u0438\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0443 \u0432 \u043d\u0443\u0436\u043d\u044b\u0439 \u0442\u0438\u043f. <\/p>\n<p>  \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u044b \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u043f\u0446\u0438\u043e\u043d\u0430\u043b, \u0442\u043e \u0435\u0441\u0442\u044c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c nil \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u0448\u0438\u0431\u043a\u0438 \u0438 \u0438\u0437\u0431\u0430\u0432\u0438\u0442\u044c\u0441\u044f \u043e\u0442 \u0433\u0440\u043e\u043c\u043e\u0437\u0434\u043a\u043e\u0439 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438. \u0418\u043d\u043e\u0433\u0434\u0430 \u044d\u0442\u043e \u0443\u0434\u043e\u0431\u043d\u0435\u0439: \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0434\u043e\u0441\u0442\u0430\u0435\u043c \u043e\u043f\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u0443\u044e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e, \u0430 \u0437\u0430\u0442\u0435\u043c \u043a \u043d\u0435\u0439 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u043c throws \u0444\u0443\u043d\u043a\u0446\u0438\u044e. \u041a\u043e\u0434 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u044c \u0432 \u043e\u0434\u0438\u043d if\/guard \u0431\u043b\u043e\u043a, \u0438 \u043e\u043d \u043e\u0441\u0442\u0430\u043d\u0435\u0442\u0441\u044f \u043b\u0430\u043a\u043e\u043d\u0438\u0447\u043d\u044b\u043c.<\/p>\n<p>  \u0412\u043e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 throws \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439:<\/p>\n<pre><code class=\"swift\">func blah() -&gt; String throws {     \tthrow NetworkError.serverError     }          do {     \tlet string = try blah()     \t\/\/ \u042d\u0442\u0430 \u0441\u0442\u0440\u043e\u0447\u043a\u0430 \u0443\u0436\u0435 \u043d\u0435 \u0432\u044b\u0437\u043e\u0432\u0435\u0442\u0441\u044f, \u0442\u0430\u043a \u043a\u0430\u043a \u0432\u0435\u0440\u0445\u043d\u044f\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u043e\u0448\u0438\u0431\u043a\u0443     \tlet anotherString = try blah()     } catch {     \t\/\/ \u0420\u0430\u0441\u043f\u0435\u0447\u0430\u0442\u0430\u0435\u0442 NetworkError.serverError     \tprint(error)     }          \/\/ \u041f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f string = nil     let string = try? blah()<\/code><\/pre>\n<p>  P.S. \u041d\u0435 \u0441\u0442\u043e\u0438\u0442 \u043f\u0443\u0442\u0430\u0442\u044c \u0441 do catch \u0432 \u0434\u0440\u0443\u0433\u0438\u0445 \u044f\u0437\u044b\u043a\u0430\u0445. \u0421\u0432\u0438\u0444\u0442 \u043d\u0435 \u0431\u0440\u043e\u0441\u0430\u0435\u0442 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435, \u0430 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043e\u0448\u0438\u0431\u043a\u0438 (\u0435\u0441\u043b\u0438 \u043e\u043d\u0430 \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u0430) \u0432 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u0440\u0435\u0433\u0438\u0441\u0442\u0440. \u041f\u0440\u0438 \u043d\u0430\u043b\u0438\u0447\u0438\u0438 \u0442\u0430\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0438\u0434\u0435\u0442 \u043f\u0435\u0440\u0435\u0445\u043e\u0434 \u0432 \u0431\u043b\u043e\u043a error, \u043f\u0440\u0438 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0438 \u2014 \u0431\u043b\u043e\u043a do \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0435\u0442\u0441\u044f. \u0418\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0438 \u0434\u043b\u044f \u0441\u0430\u043c\u044b\u0445 \u043b\u044e\u0431\u043e\u0437\u043d\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445: <a href=\"https:\/\/www.mikeash.com\/pyblog\/friday-qa-2017-08-25-swift-error-handling-implementation.html\">www.mikeash.com\/pyblog\/friday-qa-2017-08-25-swift-error-handling-implementation.html<\/a><\/p>\n<p>  \u042d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u0445\u043e\u0440\u043e\u0448 \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0445 \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u0438 \u043d\u0435 \u0442\u0430\u043a \u0443\u0434\u043e\u0431\u0435\u043d \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0434\u043e\u043b\u0433\u0438\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0437\u0430\u043f\u0440\u043e\u0441 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u043e \u0441\u0435\u0442\u0438), \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e \u0437\u0430\u043d\u044f\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438. \u0422\u043e\u0433\u0434\u0430 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 completion. <\/p>\n<p>  \u041a\u0430\u043a \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u0443 \u0432 Swift 5 \u0432\u043d\u0435\u0434\u0440\u0438\u043b\u0438 Result \u2013 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u0439 enum, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0434\u0432\u0430 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430 \u2013 success \u0438 failure. \u0421\u0430\u043c \u043f\u043e \u0441\u0435\u0431\u0435 \u043e\u043d \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 Error. \u0414\u0430 \u0438 \u043a \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0441\u0442\u0438 \u043e\u043d \u043d\u0435 \u0438\u043c\u0435\u0435\u0442 \u043f\u0440\u044f\u043c\u043e\u0433\u043e \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044f. \u041d\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u0438\u043c\u0435\u043d\u043d\u043e \u044d\u0442\u043e\u0442 \u0442\u0438\u043f \u0432 completion \u0443\u0434\u043e\u0431\u043d\u0435\u0439 \u0434\u043b\u044f \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0445 \u0441\u043e\u0431\u044b\u0442\u0438\u0439 (\u0438\u043d\u0430\u0447\u0435 \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0434\u0435\u043b\u0430\u0442\u044c \u0434\u0432\u0430 completion, success \u0438 failure, \u0438\u043b\u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u0434\u0432\u0430 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430). \u041d\u0430\u043f\u0438\u0448\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"swift\">func blah&lt;ResultType&gt;(handler: @escaping (Swift.Result&lt;ResultType, Error&gt;) -&gt; Void) { \thandler(.failure(NetworkError.serverError) }  blah&lt;String&gt;(handler { result in  \tswitch result { \t\tcase .success(let value): \t\t\tprint(value) \t\tcase .failure(let error): \t\t\tprint(error) \t} })<\/code><\/pre>\n<p>  \u042d\u0442\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043d\u0430\u043c \u0432\u043f\u043e\u043b\u043d\u0435 \u0445\u0432\u0430\u0442\u0438\u0442 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b.<\/p>\n<p>  \u0415\u0449\u0435 \u0440\u0430\u0437, \u043a\u0440\u0430\u0442\u043a\u043e:<\/p>\n<ul>\n<li>\u041e\u0448\u0438\u0431\u043a\u0438 \u0432 Swift \u2014 \u044d\u0442\u043e \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b<\/li>\n<li>\u0423\u0434\u043e\u0431\u043d\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0438 \u0432 \u0432\u0438\u0434\u0435 enum<\/li>\n<li>\u0415\u0441\u0442\u044c \u0434\u0432\u0430 \u0441\u043f\u043e\u0441\u043e\u0431\u0430 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043e\u0448\u0438\u0431\u043a\u0430\u043c\u0438 \u2013 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0439 (do catch) \u0438 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0439 (\u0432\u0430\u0448 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 competion \u0438\u043b\u0438 Result)<\/li>\n<\/ul>\n<h3>\u0422\u0435\u043a\u0441\u0442 \u043e\u0448\u0438\u0431\u043a\u0438<\/h3>\n<p>  \u0412\u0435\u0440\u043d\u0435\u043c\u0441\u044f \u043a \u0442\u0435\u043c\u0435 \u0441\u0442\u0430\u0442\u044c\u0438. \u0412 \u043f\u0430\u0440\u0430\u0433\u0440\u0430\u0444\u0435 \u0432\u044b\u0448\u0435 \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u043b\u0438 \u0441\u0432\u043e\u0439 \u0442\u0438\u043f \u043e\u0448\u0438\u0431\u043e\u043a. \u0412\u043e\u0442 \u043e\u043d:<\/p>\n<pre><code class=\"swift\">enum NetworkError: Error {         \/\/ \u041b\u044e\u0431\u043e\u0439 500 \u043a\u043e\u0434 \tcase serverError         \/\/ \u041e\u0442\u0432\u0435\u0442 \u043d\u0435 \u0442\u0430\u043a\u043e\u0439, \u043a\u0430\u043a \u043c\u044b \u043e\u0436\u0438\u0434\u0430\u0435\u043c \tcase responseError         \/\/ \u041e\u0442\u0432\u0435\u0442\u0430 \u043d\u0435\u0442, \u043e\u0442\u0432\u0430\u043b\u0438\u043b\u0438\u0441\u044c \u043f\u043e \u0442\u0430\u0439\u043c\u0430\u0443\u0442\u0443, \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0441\u0435\u0442\u044c \tcase internetError }<\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043a\u0430\u0436\u0434\u0443\u044e \u043e\u0448\u0438\u0431\u043a\u0443 \u043d\u0430\u043c \u043d\u0430\u0434\u043e \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0441 \u0442\u0435\u043a\u0441\u0442\u043e\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043d\u044f\u0442\u0435\u043d \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e. \u0415\u0433\u043e \u043c\u044b \u0432\u044b\u0432\u0435\u0434\u0435\u043c \u0432 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u0448\u0438\u0431\u043a\u0438. \u041d\u0430 \u043f\u043e\u043c\u043e\u0449\u044c \u043d\u0430\u043c \u0441\u043f\u0435\u0448\u0438\u0442 LocalizedError Protocol. \u041e\u043d \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u0442 protocol Error \u0438 \u0434\u043e\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0435\u0433\u043e 4 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430\u043c\u0438:<\/p>\n<pre><code class=\"swift\">protocol LocalizedError : Error {     var errorDescription: String? { get }     var failureReason: String? { get }     var recoverySuggestion: String? { get }     var helpAnchor: String? { get } }<\/code><\/pre>\n<p>  \u0420\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b:<\/p>\n<pre><code class=\"swift\">extension NetworkError: LocalizedError {     \tvar errorDescription: String? {             switch self {             case .serverError, .responseError:                 return &quot;Error&quot;     \t    case .internetError:                 return &quot;No Internet Connection&quot;             }         }              var failureReason: String? {             switch self {             case .serverError, .responseError:                 return &quot;Something went wrong&quot;     \t    case .internetError:                 return nil             }         }              var recoverySuggestion: String? {             switch self {             case .serverError, .responseError:                 return &quot;Please, try again&quot;     \t    case .internetError:                 return &quot;Please check your internet connection and try again&quot;             }         }     }<\/code><\/pre>\n<p>  \u041f\u043e\u043a\u0430\u0437 \u043e\u0448\u0438\u0431\u043a\u0438 \u043f\u043e\u0447\u0442\u0438 \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u0441\u044f:<\/p>\n<pre><code class=\"swift\">\tif let error = error { \t\tlet errorMessage = [error.failureReason, error.recoverySuggestion].compactMap({ $0 }).joined(separator: &quot;. &quot;) \t\tlet alertVC = UIAlertController( \t\t\ttitle: error.errorDescription, \t\t\tmessage: errorMessage, \t\t\tpreferredStyle: .alert) \t\tlet action = UIAlertAction(title: &quot;OK&quot;, style: .default) { (_) -&gt; Void in } \t\talertVC.addAction(action) \t\tself.present(alertVC, animated: true, competion: nil)<\/code><\/pre>\n<p>  \u041e\u0442\u043b\u0438\u0447\u043d\u043e, \u0441 \u0442\u0435\u043a\u0441\u0442\u043e\u043c \u0432\u0441\u0435 \u0431\u044b\u043b\u043e \u043b\u0435\u0433\u043a\u043e. \u041f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u043a\u043d\u043e\u043f\u043a\u0430\u043c\u0438. <\/p>\n<h3>\u0412\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0438\u0437 \u043e\u0448\u0438\u0431\u043e\u043a<\/h3>\n<p>  \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043e\u0448\u0438\u0431\u043e\u043a \u0432 \u0432\u0438\u0434\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0434\u0438\u0430\u0433\u0440\u0430\u043c\u043c\u044b. \u0414\u043b\u044f \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438, \u043a\u043e\u0433\u0434\u0430 \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043e\u0448\u0438\u0431\u043a\u0438 \u043c\u044b \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u0434\u0438\u0430\u043b\u043e\u0433\u043e\u0432\u043e\u0435 \u043e\u043a\u043d\u043e \u0441 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430\u043c\u0438 Try Again, Cancel \u0438, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u043a\u0430\u043a\u0438\u043c\u0438-\u0442\u043e \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u0447\u043d\u044b\u043c\u0438, \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0441\u0445\u0435\u043c\u0443:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/a9\/te\/n3\/a9ten3zbrffm7sz8kkupfo8xsuy.png\"><\/p>\n<p>  \u041d\u0430\u0447\u043d\u0435\u043c \u0440\u0435\u0448\u0430\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0443 \u0441 \u043a\u043e\u043d\u0446\u0430. \u041d\u0430\u043c \u043d\u0443\u0436\u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0430\u043b\u0435\u0440\u0442 \u0441 n + 1 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430\u043c\u0438. \u041d\u0430\u043a\u0438\u0434\u0430\u0435\u043c, \u043a\u0430\u043a \u0431\u044b \u043d\u0430\u043c \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0443:<\/p>\n<pre><code class=\"swift\">struct RecovableAction {     \tlet title: String     \tlet action: () -&gt; Void     }          func showRecovableOptions(actions: [RecovableAction], from viewController: UIViewController) {     \tlet alertActions = actions.map { UIAlertAction(name: $0.title, action: $0.action) }     \tlet cancelAction = UIAlertAction(name: &quot;Cancel&quot;, action: nil)     \tlet alertController = UIAlertController(actions: alertActions)     \tviewController.present(alertController, complition: nil)     }<\/code><\/pre>\n<p>  \u0424\u0443\u043d\u043a\u0446\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u0442\u0438\u043f \u043e\u0448\u0438\u0431\u043a\u0438 \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442 \u0441\u0438\u0433\u043d\u0430\u043b \u043a \u043f\u043e\u043a\u0430\u0437\u0443 \u0430\u043b\u0435\u0440\u0442\u0430:<\/p>\n<pre><code class=\"swift\">func handleError(error: Error) { \tif error is RecovableError { \t\tshowRecovableOptions(actions: error.actions, from: viewController) \t\treturn \t} \tshowErrorAlert(...) } <\/code><\/pre>\n<p>  \u0418 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u043d\u044b\u0439 \u0442\u0438\u043f \u043e\u0448\u0438\u0431\u043a\u0438, \u0443 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0435\u0441\u0442\u044c \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0438 \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0440\u0438 \u0442\u043e\u043c \u0438\u043b\u0438 \u0438\u043d\u043e\u043c \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0435.<\/p>\n<pre><code class=\"swift\">struct RecovableError: Error { \tlet recovableACtions: [RecovableAction] \tlet context: Context }<\/code><\/pre>\n<p>  \u0412 \u0433\u043e\u043b\u043e\u0432\u0435 \u0441\u0440\u0430\u0437\u0443 \u0440\u0438\u0441\u0443\u0435\u0442\u0441\u044f \u0441\u0445\u0435\u043c\u0430 \u0441\u0432\u043e\u0435\u0433\u043e \u0432\u0435\u043b\u043e\u0441\u0438\u043f\u0435\u0434\u0430. \u041d\u043e \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u0434\u043e\u043a\u0438 Apple. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0447\u0430\u0441\u0442\u044c \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0430 \u0443\u0436\u0435 \u0435\u0441\u0442\u044c \u0443 \u043d\u0430\u0441 \u0432 \u0440\u0443\u043a\u0430\u0445. <\/p>\n<h3>\u041d\u0430\u0442\u0438\u0432\u043d\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f?<\/h3>\n<p>  \u041d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u043e\u0438\u0441\u043a\u0430 \u0432 \u0418\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u0442 \u043a protocol RecoverableError (https:\/\/developer.apple.com\/documentation\/foundation\/recoverableerror):<\/p>\n<pre><code class=\"swift\">\/\/ A specialized error that may be recoverable by presenting several potential recovery options to the user. protocol RecoverableError : Error {     var recoveryOptions: [String] { get }      func attemptRecovery(optionIndex recoveryOptionIndex: Int, resultHandler handler: @escaping (Bool) -&gt; Void)     func attemptRecovery(optionIndex recoveryOptionIndex: Int) -&gt; Bool }<\/code><\/pre>\n<p>  \u041f\u043e\u0445\u043e\u0436\u0435 \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u043c\u044b \u0438\u0449\u0435\u043c:  <\/p>\n<ul>\n<li>recoveryOptions: [String] \u2013 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e, \u0445\u0440\u0430\u043d\u044f\u0449\u0435\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f<\/li>\n<li>func attemptRecovery(optionIndex: Int) -&gt; Bool \u2013 \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u0438\u0437 \u043e\u0448\u0438\u0431\u043a\u0438, \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e. True \u2013 \u043f\u0440\u0438 \u0443\u0441\u043f\u0435\u0445\u0435<\/li>\n<li>func attemptRecovery(optionIndex: Int, resultHandler: (Bool) -&gt; Void) \u2013 \u0410\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442, \u0438\u0434\u0435\u044f \u0442\u0430 \u0436\u0435<\/li>\n<\/ul>\n<p>  \u0421 \u0433\u0430\u0439\u0434\u0430\u043c\u0438 \u043f\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044e \u0432\u0441\u0435 \u0441\u043a\u0440\u043e\u043c\u043d\u0435\u0435. \u041d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043f\u043e\u0438\u0441\u043a \u043f\u043e \u0441\u0430\u0439\u0442\u0443 Apple \u0438 \u043e\u043a\u0440\u0435\u0441\u0442\u043d\u043e\u0441\u0442\u044f\u043c \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a <a href=\"https:\/\/developer.apple.com\/library\/archive\/documentation\/Cocoa\/Conceptual\/ErrorHandlingCocoa\/RecoverFromErrors\/RecoverFromErrors.html#\/\/apple_ref\/doc\/uid\/TP40001806-CH206-BCIDEGGF\">\u0441\u0442\u0430\u0442\u044c\u0435 \u043e\u0431 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u043e\u0448\u0438\u0431\u043e\u043a<\/a>, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0439 \u0434\u043e \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u0445 \u0430\u043d\u043e\u043d\u0441\u043e\u0432 \u0421\u0432\u0438\u0444\u0442. <\/p>\n<p>  \u041a\u0440\u0430\u0442\u043a\u043e:  <\/p>\n<ul>\n<li>\u041c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u043f\u0440\u0438\u0434\u0443\u043c\u0430\u043d \u0434\u043b\u044f MacOs \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u0438 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0434\u0438\u0430\u043b\u043e\u0433\u043e\u0432\u043e\u0435 \u043e\u043a\u043d\u043e<\/li>\n<li>\u041e\u043d \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d \u0432\u043e\u043a\u0440\u0443\u0433 NSError<\/li>\n<li>\u0412\u043d\u0443\u0442\u0440\u044c \u043e\u0448\u0438\u0431\u043a\u0438 \u0432 userInfo \u0438\u043d\u043a\u0430\u043f\u0441\u0443\u043b\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043e\u0431\u044a\u0435\u043a\u0442 RecoveryAttempter, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0437\u043d\u0430\u0435\u0442 \u043e\u0431 \u0443\u0441\u043b\u043e\u0432\u0438\u044f\u0445 \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u043e\u0432\u0435\u043d\u0438\u044f \u043e\u0448\u0438\u0431\u043a\u0438 \u0438 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0434\u043e\u0431\u0440\u0430\u0442\u044c \u043d\u0430\u0438\u043b\u0443\u0447\u0448\u0438\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b. \u041e\u0431\u044a\u0435\u043a\u0442 \u043d\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0440\u0430\u0432\u0435\u043d nil<\/li>\n<li>RecoveryAttempter \u0434\u043e\u043b\u0436\u0435\u043d \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c \u043d\u0435\u0444\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b NSErrorRecoveryAttempting<\/li>\n<li>\u0422\u0430\u043a\u0436\u0435 \u0432 userInfo \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c recovery option<\/li>\n<li>\u0418 \u0432\u0441\u0435 \u0437\u0430\u0432\u044f\u0437\u0430\u043d\u043e \u043d\u0430 \u0432\u044b\u0437\u043e\u0432 \u043c\u0435\u0442\u043e\u0434\u0430 presentError, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0435\u0441\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0432 SDK macOS. \u041e\u043d \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0430\u043b\u0435\u0440\u0442<\/li>\n<li>\u0415\u0441\u043b\u0438 \u0430\u043b\u0435\u0440\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u043d \u0447\u0435\u0440\u0435\u0437 presentError, \u0442\u043e \u043f\u0440\u0438 \u0432\u044b\u0431\u043e\u0440\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430 \u0432 \u0432\u0441\u043f\u043b\u044b\u0432\u0430\u044e\u0449\u0435\u043c \u043e\u043a\u043d\u0435 \u0432 AppDelegate \u0434\u0435\u0440\u043d\u0435\u0442\u0441\u044f \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f:<\/li>\n<\/ul>\n<pre><code class=\"swift\">func attemptRecovery(fromError error: Error, optionIndex recoveryOptionIndex: Int, delegate: Any?, didRecoverSelector: Selector?, contextInfo: UnsafeMutableRawPointer?)<\/code><\/pre>\n<p>  \u041d\u043e \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0443 \u043d\u0430\u0441 \u043d\u0435\u0442 presentError \u2013 \u0434\u0435\u0440\u043d\u0443\u0442\u044c \u0435\u0435 \u043d\u0435 \u0443\u0434\u0430\u0435\u0442\u0441\u044f.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/vp\/xo\/cj\/vpxocjapqc5ywmiq8hhq3djow6o.gif\"><\/p>\n<p>  \u041d\u0430 \u044d\u0442\u043e\u043c \u043c\u043e\u043c\u0435\u043d\u0442\u0435 \u0447\u0443\u0432\u0441\u0442\u0432\u0443\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u043c\u044b \u043e\u0442\u043a\u0430\u043f\u0430\u043b\u0438 \u0441\u043a\u043e\u0440\u0435\u0435 \u0442\u0440\u0443\u043f, \u0447\u0435\u043c \u043a\u043b\u0430\u0434. \u041d\u0430\u043c \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0442\u044c Error \u0432 NSError \u0438 \u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0432\u043e\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0434\u043b\u044f \u043f\u043e\u043a\u0430\u0437\u0430 \u0430\u043b\u0435\u0440\u0442\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u043c. \u041a\u0443\u0447\u0430 \u043d\u0435\u044f\u0432\u043d\u044b\u0445 \u0441\u0432\u044f\u0437\u0435\u0439. \u041c\u043e\u0436\u043d\u043e, \u0441\u043b\u043e\u0436\u043d\u043e \u0438 \u043d\u0435 \u0441\u043e\u0432\u0441\u0435\u043c \u043f\u043e\u043d\u044f\u0442\u043d\u043e \u2013 \u00ab\u0417\u0430\u0447\u0435\u043c?\u00bb.<\/p>\n<p>  \u041f\u043e\u043a\u0430 \u0437\u0430\u0432\u0430\u0440\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u0430\u044f \u0447\u0430\u0448\u043a\u0430 \u0447\u0430\u044f, \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0434\u0443\u043c\u0430\u0442\u044c, \u043f\u043e\u0447\u0435\u043c\u0443 \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432\u044b\u0448\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f delegate \u043a\u0430\u043a Any \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f \u0441\u0435\u043b\u0435\u043a\u0442\u043e\u0440. \u041e\u0442\u0432\u0435\u0442 \u043d\u0438\u0436\u0435:<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041e\u0442\u0432\u0435\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\u0424\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u043a \u043d\u0430\u043c \u0438\u0437 \u0432\u0440\u0435\u043c\u0435\u043d iOS 2. \u0418 \u0432 \u0442\u043e \u0432\u0440\u0435\u043c\u044f \u0432 \u044f\u0437\u044b\u043a\u0435 \u043d\u0435 \u0431\u044b\u043b\u043e \u0434\u0430\u0436\u0435 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u043e\u0432! \u0415\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c \u0431\u044b\u043b\u043e \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u0443 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u044b\u0439 \u0441\u0435\u043b\u0435\u043a\u0442\u043e\u0440 (\u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0432, \u0447\u0442\u043e \u043e\u043d \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442\u0441\u044f). \u0411\u044b\u043b\u0438 \u0432\u0440\u0435\u043c\u0435\u043d\u0430:)  <\/div>\n<\/div>\n<h3>\u0421\u0442\u0440\u043e\u0438\u043c \u0432\u0435\u043b\u043e\u0441\u0438\u043f\u0435\u0434 <\/h3>\n<p>  \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0432\u0441\u0435 \u0436\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b, \u043d\u0430\u043c \u043d\u0435 \u043f\u043e\u0432\u0440\u0435\u0434\u0438\u0442:<\/p>\n<pre><code class=\"swift\">struct RecoverableError: Foundation.RecoverableError { \tlet error: Error \tvar recoveryOptions: [String] { \t\treturn [&quot;Try again&quot;]s \t} \t \tfunc attemptRecovery(optionIndex recoveryOptionIndex: Int) -&gt; Bool { \t\t\/\/ \u0414\u0435\u043b\u0430\u0435\u043c \u0437\u0430\u0433\u043b\u0443\u0448\u043a\u0443, \u0432 \u0431\u0443\u0434\u0443\u0449\u0435\u043c \u0431\u0443\u0434\u0443\u0442 \u0443\u0441\u043b\u043e\u0432\u0438\u044f \t\treturn true \t} \t \tfunc attemptRecovery(optionIndex: Int, resultHandler: (Bool) -&gt; Void) { \t\t\/\/ \u0418\u043d\u0434\u0435\u043a\u0441\u044b \u043d\u0435 \u0441\u0430\u043c\u044b\u0439 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0440\u0430\u0431\u043e\u0442\u044b.                 \/\/ \u0412 \u0431\u0443\u0434\u0443\u0449\u0435\u043c \u043f\u043e\u043f\u044b\u0442\u0430\u0435\u043c\u0441\u044f \u043e\u0442 \u043d\u0438\u0445 \u0438\u0437\u0431\u0430\u0432\u0438\u0442\u044c\u0441\u044f \t\tswitch optionIndex { \t\t\tcase 0: \t\t\t\tresultHandler(true) \t\t\tdefault:  \t\t\t\tresultHandler(false) \t} }<\/code><\/pre>\n<p>  \u0417\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0438 \u043e\u0442 \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u2013 \u043d\u0435 \u0441\u0430\u043c\u043e\u0435 \u0443\u0434\u043e\u0431\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 (\u043c\u044b \u043b\u0435\u0433\u043a\u043e \u043c\u043e\u0436\u0435\u043c \u0432\u044b\u0439\u0442\u0438 \u0437\u0430 \u043f\u0440\u0435\u0434\u0435\u043b\u044b \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0438 \u043a\u0440\u0430\u0448\u043d\u0443\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435). \u041d\u043e \u0434\u043b\u044f MVP \u0441\u043e\u0439\u0434\u0451\u0442. \u0412\u043e\u0437\u044c\u043c\u0435\u043c \u0438\u0434\u0435\u044e Apple, \u043f\u0440\u043e\u0441\u0442\u043e \u043e\u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u0438\u043c \u0435\u0435. \u041d\u0430\u043c \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u0441\u044f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 Attempter \u0438 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b \u043a\u043d\u043e\u043f\u043e\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u0435\u043c\u0443 \u0437\u0430\u0434\u0430\u0434\u0438\u043c:<\/p>\n<pre><code class=\"swift\">struct RecoveryAttemper {     \t\/\/ \u041c\u0430\u0441\u0441\u0438\u0432 \u0441 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430\u043c\u0438     \tprivate let _recoveryOptions: [RecoveryOptions]          \tvar recoveryOptionsText: [String] {     \t\treturn _recoveryOptions.map({ $0.title })     \t}          \tinit(options: [RecoveryOptions] {     \t\t_recoveryOptions = recoveryOptions     \t}          \t\/\/ \u041f\u0435\u0440\u0435\u0442\u0430\u0449\u0438\u043c \u0441\u044e\u0434\u0430 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u043e\u0448\u0438\u0431\u043e\u043a     \tfunc attemptRecovery(fromError error: Error, optionIndex: Int) -&gt; Bool {     \t\tlet option = _recoveryOptions[optionIndex]     \t\t\t\tswitch option {     \t\t\t\tcase .tryAgain(let action)     \t\t\t\t\taction()     \t\t\t\t\treturn true     \t\t\t\tcase .cancel:     \t\t\t\t\treturn false     \t\t\t\t}     \t\t}     }          \/\/ \u0420\u0430\u0441\u0448\u0438\u0440\u044f\u0435\u043c\u044b\u0439 enum, \u0441\u044e\u0434\u0430 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0441\u043a\u043b\u0430\u0434\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b \u043e\u0448\u0438\u0431\u043e\u043a     enum RecoveryOptions {     \t\/\/ \u0417\u0430\u0445\u0432\u0430\u0442\u0438\u043c \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0434\u043b\u044f \u043f\u043e\u0432\u0442\u043e\u0440\u0435\u043d\u0438\u044f \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440)     \tcase tryAgain(action: (() -&gt; Void))     \tcase cancel     }<\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u0434\u043e \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0443. \u042f \u043e\u0447\u0435\u043d\u044c \u043b\u044e\u0431\u043b\u044e \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u044b, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0431\u0443\u0434\u0443 \u0440\u0435\u0448\u0430\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0443 \u0447\u0435\u0440\u0435\u0437 \u043d\u0438\u0445. \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f UIAlertController \u0438\u0437 \u043e\u0448\u0438\u0431\u043e\u043a:<\/p>\n<pre><code class=\"swift\">protocol ErrorAlertCreatable: class, ErrorReasonExtractable {     \t\/\/ \u0421\u043e\u0437\u0434\u0430\u0435\u0442 \u0430\u043b\u0435\u0440\u0442 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0435\u0440 \u0438\u0437 \u043e\u0448\u0438\u0431\u043a\u0438     \tfunc createAlert(for error: Error) -&gt; UIAlertController     }          \/\/ MARK: - Default implementation     extension ErrorAlertCreatable where Self: UIViewController {     \tfunc createAlert(for error: Error) -&gt; UIAlertController {     \t\t\/\/ \u0414\u043b\u044f \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c\u043e\u0439 \u043e\u0448\u0438\u0431\u043a\u0438 \u0441\u043e\u0431\u0435\u0440\u0435\u043c \u043e\u0441\u043e\u0431\u044b\u0439 \u0430\u043b\u0435\u0440\u0442     \t\tif let recoverableError = error as? RecoverableError {     \t\t\treturn createRecoverableAlert(for: recoverableError)     \t\t}     \t\tlet defaultTitle = &quot;Error&quot;     \t\tlet description = errorReason(from: error)          \t\t\/\/ \u0414\u043b\u044f \u043e\u0448\u0438\u0431\u043a\u0438 \u0441 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0430\u043b\u0435\u0440\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0441 \u043a\u043d\u043e\u043f\u043a\u043e\u0439 \u041e\u041a     \t\tif let localizedError = error as? LocalizedError {     \t\t\treturn createAlert(     \t\t\t\ttitle: localizedError.errorDescription ?? defaultTitle,     \t\t\t\tmessage: description,     \t\t\t\tactions: [.okAction],     \t\t\t\taboveAll: aboveAll)     \t\t}          \t\treturn createAlert(title: defaultTitle, message: description, actions: [.okAction])     \t}          \tfileprivate func createAlert(title: String?, message: String?, actions: [UIAlertAction]) -&gt; UIAlertController {     \t\tlet alertViewController = UIAlertController(title: title, message: message, preferredStyle: .alert)     \t\tactions.forEach({ alertViewController.addAction($0) })     \t\treturn alertViewController     \t}          \tfileprivate func createRecoverableAlert(for recoverableError: RecoverableError) -&gt; UIAlertController {     \t\tlet title = recoverableError.errorDescription     \t\tlet message = recoverableError.recoverySuggestion     \t\t\/\/ \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043a\u043d\u043e\u043f\u043a\u0438 \u0438\u0437 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0445 \u043e\u043f\u0446\u0438\u0439.      \t\tlet actions = recoverableError.recoveryOptions.enumerated().map { (element) -&gt; UIAlertAction in     \t\tlet style: UIAlertAction.Style = element.offset == 0 ? .cancel : .default     \t\treturn UIAlertAction(title: element.element, style: style) { _ in     \t\t\trecoverableError.attemptRecovery(optionIndex: element.offset)     \t\t      }     \t\t}     \t\treturn createAlert(title: title, message: message, actions: actions)     \t}          \tfunc createOKAlert(with text: String) -&gt; UIAlertController {     \t\treturn createAlert(title: text, message: nil, actions: [.okAction])     \t}     }          extension ERror          \/\/ \u0423\u0434\u043e\u0431\u043d\u044b\u0439 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u0434\u043b\u044f \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f ok     extension UIAlertAction {     \tstatic let okAction = UIAlertAction(title: &quot;OK&quot;, style: .cancel) { (_) -&gt; Void in }     }          \/\/ \u0412\u044b\u0442\u0430\u0441\u043a\u0438\u0432\u0430\u0435\u043c \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043e\u0448\u0438\u0431\u043a\u0438      protocol ErrorReasonExtractable {     \tfunc errorReason(from error: Error) -&gt; String?     }          \/\/ MARK: - Default implementation     extension ErrorReasonExtractable {     \tfunc errorReason(from error: Error) -&gt; String? {     \t\tif let localizedError = error as? LocalizedError {     \t\t\treturn localizedError.recoverySuggestion     \t\t}     \t\treturn &quot;Something bad happened. Please try again&quot;     \t}     }<\/code><\/pre>\n<p>  \u0418 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b \u0434\u043b\u044f \u043f\u043e\u043a\u0430\u0437\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0445 \u0430\u043b\u0435\u0440\u0442\u043e\u0432:<\/p>\n<pre><code class=\"swift\">protocol ErrorAlertPresentable: class { \tfunc presentAlert(from error: Error) }  \/\/ MARK: - Default implementation extension ErrorAlertPresentable where Self: ErrorAlertCreatable &amp; UIViewController { \tfunc presentAlert(from error: Error) { \t\tlet alertVC = createAlert(for: error) \t\tpresent(alertVC, animated: true, completion: nil) \t} }<\/code><\/pre>\n<p>  \u041f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u0433\u0440\u043e\u043c\u043e\u0437\u0434\u043a\u043e, \u043d\u043e \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c\u043e. \u041c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0435 \u0441\u043f\u043e\u0441\u043e\u0431\u044b \u043f\u043e\u043a\u0430\u0437\u0430 \u043e\u0448\u0438\u0431\u043a\u0438 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, toast \u0438\u043b\u0438 \u043f\u043e\u043a\u0430\u0437 \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u043e\u0433\u043e \u0432\u044c\u044e) \u0438 \u043f\u0440\u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0434\u0435\u0444\u043e\u043b\u0442\u043d\u0443\u044e \u0438\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e, \u043d\u0435 \u043c\u0435\u043d\u044f\u044f \u043d\u0438\u0447\u0435\u0433\u043e \u0432 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c\u043e\u043c \u043c\u0435\u0442\u043e\u0434\u0435. <\/p>\n<p>  \u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u0435\u0441\u043b\u0438 \u0431\u044b \u043d\u0430\u0448 view \u0431\u044b\u043b \u043f\u0440\u0438\u043a\u0440\u044b\u0442 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u043e\u043c:<\/p>\n<pre><code class=\"swift\">protocol ViewControllerInput: class {      \/\/ \u041d\u0430\u0431\u043e\u0440 \u043c\u0435\u0442\u043e\u0434\u043e\u0432     }     extension ViewControllerInput: ErrorAlertPresentable { }          extension ViewController: ErrorAlertCreatable { }     \/\/ \u0421\u0430\u043c\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f, \u0441\u043a\u0440\u044b\u0442\u0430\u044f \u0437\u0430 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u043e\u043c \u043c\u043e\u0436\u0435\u0442 \u043b\u0435\u0433\u043a\u043e \u043c\u0435\u043d\u044f\u0442\u044c \u0441\u043f\u043e\u0441\u043e\u0431 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0430\u043b\u0435\u0440\u0442\u0430, \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044f \u043d\u0443\u0436\u043d\u044b\u0439 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b      \/\/ \u0438\u043b\u0438 \u0437\u0430\u0434\u0430\u0432 \u0441\u0432\u043e\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e          \/\/ \u041c\u044b \u043c\u043e\u0433\u043b\u0438 \u0431\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b \u0434\u043b\u044f &quot;\u0442\u043e\u0441\u0442\u043e\u0432&quot;, \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0438\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e \u0432 ErrorAlertPresentable \u0438 \u0437\u0430\u043c\u0435\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u0447\u043a\u0438 \u043a\u043e\u0434\u0430 \u043f\u043e\u043c\u0435\u043d\u044f\u0442\u044c \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435.      extension ViewController: ErrorToastCreatable { }<\/code><\/pre>\n<p>  \u041d\u043e \u043d\u0430\u0448 \u043f\u0440\u0438\u043c\u0435\u0440 \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u043f\u0440\u043e\u0449\u0435, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u043c \u043e\u0431\u0430 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430 \u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435:<\/p>\n<pre><code class=\"swift\">func requestFeed(...) {     \t\tservice.requestObject { [weak self] (result) in     \t\t\tguard let `self` = self else { return }     \t\t\tswitch result {     \t\t\tcase .success:     \t\t\t\tbreak     \t\t\tcase .failure(let error):     \t\t\t\t\/\/ \u0417\u0430\u0445\u0432\u0430\u0442\u0438\u043c \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0441 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438 \u0438 \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u044b\u0439 \u0432\u044b\u0437\u043e\u0432 \u0442\u043e\u0439 \u0436\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438     \t\t\t\t\/\/ \u0418\u0437-\u0437\u0430 \u0441\u0438\u043b\u044c\u043d\u043e\u0439 \u0441\u0441\u044b\u043b\u043a\u0438 \u0437\u0430\u0445\u0432\u0430\u0447\u0435\u043d\u043d\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 (\u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 viewController) \u043d\u0435 \u0443\u043c\u0440\u0435\u0442,     \t\t\t\t\/\/ \u043f\u043e\u043a\u0430 \u0431\u043b\u043e\u043a \u043d\u0435 \u0432\u044b\u0437\u043e\u0432\u0435\u0442\u0441\u044f. \u0418\u043b\u0438 \u043d\u0435 \u0443\u043c\u0440\u0435\u0442 \u043e\u0431\u044a\u0435\u043a\u0442 tryAgainOption      \t\t\t\tlet tryAgainOption = RecoveryOptions.tryAgain {     \t\t\t\t\tself.requestFeed(...)     \t\t\t\t}     \t\t\t\tlet recoveryOptions = [tryAgainOption]     \t\t\t\tlet attempter = RecoveryAttemper(recoveryOptions: recoveryOptions)     \t\t\t\tlet recovableError = RecoverableError(error: error, attempter: attempter)     \t\t\t\tself.presentAlert(from: recovableError)     \t\t\t}     \t\t}     \t}          \/\/ MARK: - ErrorAlertCreatable     extension ViewController: ErrorAlertCreatable { }          \/\/ MARK: - ErrorAlertPresentable     extension ViewController: ErrorAlertPresentable { }<\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/3h\/fl\/vh\/3hflvhmxpfkuzgskzcpe9hodl2k.png\"><\/p>\n<p>  \u0412\u0440\u043e\u0434\u0435 \u0432\u0441\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c. \u041e\u0434\u043d\u043e \u0438\u0437 \u043f\u0435\u0440\u0432\u043e\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u0445 \u0443\u0441\u043b\u043e\u0432\u0438\u0439 \u0431\u044b\u043b\u043e \u0432 2-3 \u0441\u0442\u0440\u043e\u0447\u043a\u0438. \u0420\u0430\u0441\u0448\u0438\u0440\u0438\u043c \u043d\u0430\u0448 attempter \u0443\u0434\u043e\u0431\u043d\u044b\u043c \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u043e\u043c:<\/p>\n<pre><code class=\"swift\">struct RecoveryAttemper {     \t\/\/     \t...     \t\/\/     \tstatic func tryAgainAttempter(block: @escaping (() -&gt; Void)) -&gt; Self {     \t\treturn RecoveryAttemper(recoveryOptions: [.cancel, .tryAgain(action: block)])     \t}     }               func requestFeed() {     \t\tservice.requestObject { [weak self] (result) in     \t\t\tguard let `self` = self else { return }     \t\t\tswitch result {     \t\t\tcase .success:     \t\t\t\tbreak     \t\t\tcase .failure(let error):     \t\t\t\t\/\/ \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442\u0441\u044f \u0434\u043e \u0441\u0442\u0440\u043e\u0447\u043a\u0438     \t\t\t\tlet recovableError = RecoverableError(error: error, attempter: .tryAgainAttempter(block: {     \t\t\t\t\tself.requestFeed()     \t\t\t\t}))     \t\t\t\tself.presentAlert(from: recovableError)     \t\t\t}     \t\t}     \t}<\/code><\/pre>\n<p>  \u041c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 MVP-\u0440\u0435\u0448\u0435\u043d\u0438\u0435, \u0438 \u043d\u0430\u043c \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0441\u043b\u043e\u0436\u043d\u043e \u0432 \u043b\u044e\u0431\u043e\u043c \u043c\u0435\u0441\u0442\u0435 \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0435\u0433\u043e. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043d\u0430\u0447\u043d\u0435\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c edge-\u043a\u0435\u0439\u0441\u044b \u0438 \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u0443\u0435\u043c\u043e\u0441\u0442\u044c.<\/p>\n<h3>\u0427\u0442\u043e \u0435\u0441\u043b\u0438 \u0443 \u043d\u0430\u0441 \u0431\u0443\u0434\u0435\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0435\u0432 \u0432\u044b\u0445\u043e\u0434\u0430 \u0438\u0437 \u043e\u0448\u0438\u0431\u043a\u0438?<\/h3>\n<p>  \u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u0432 \u043d\u0430\u0448\u0435\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u0443 \u044e\u0437\u0435\u0440\u0430 \u0435\u0441\u0442\u044c \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435. \u0423 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430 \u0435\u0441\u0442\u044c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u043f\u043e \u043c\u0435\u0441\u0442\u0443. \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0435\u0441\u0442\u044c \u0434\u0432\u0430 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u044f \u0434\u043b\u044f \u0432\u044b\u0445\u043e\u0434\u0430 \u0438\u0437 \u043e\u0448\u0438\u0431\u043a\u0438: \u044e\u0437\u0435\u0440 \u043c\u043e\u0436\u0435\u0442 \u043b\u0438\u0431\u043e \u043e\u0441\u0432\u043e\u0431\u043e\u0434\u0438\u0442\u044c \u043c\u0435\u0441\u0442\u043e, \u043b\u0438\u0431\u043e \u043a\u0443\u043f\u0438\u0442\u044c \u0435\u0449\u0435. \u041d\u0430\u043f\u0438\u0448\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434:<\/p>\n<pre><code class=\"swift\">\/\/ \u0412\u043d\u0443\u0442\u0440\u0438 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0435\u0440\u0430     func runOutOfSpace() {     \t\tservice.runOfSpace { [weak self] (result) in     \t\t\tguard let `self` = self else { return }     \t\t\tswitch result {     \t\t\tcase .success:     \t\t\t\tbreak     \t\t\tcase .failure(let error):     \t\t\t\tlet notEnoughSpace = RecoveryOptions.freeSpace {     \t\t\t\t\tself.freeSpace()     \t\t\t\t}          \t\t\t\tlet buyMoreSpace = RecoveryOptions.buyMoreSpace {     \t\t\t\t\tself.buyMoreSpace()     \t\t\t\t}     \t\t\t\tlet options = [notEnoughSpace, buyMoreSpace]     \t\t\t\tlet recovableError = RecoverableError(error: error, attempter: .cancalableAttemter(options: options))     \t\t\t\tself.presentAlert(from: recovableError)     \t\t\t}     \t\t}     \t}          \tfunc freeSpace() {     \t\tlet alertViewController = createOKAlert(with: &quot;Free space selected&quot;)     \t\tpresent(alertViewController, animated: true, completion: nil)     \t}          \tfunc buyMoreSpace() {     \t\tlet alertViewController = createOKAlert(with: &quot;Buy more space selected&quot;)     \t\tpresent(alertViewController, animated: true, completion: nil)     \t}               struct RecoveryAttemper {     \t\/\/     \t...     \t\/\/     \tstatic func cancalableAttemter(options: [RecoveryOptions]) -&gt; Self {     \t\treturn RecoveryAttemper(recoveryOptions: [.cancel] + options)     \t}     } <\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/d5\/eg\/zq\/d5egzquyykwxtjorhevcq2pe1mg.png\"><\/p>\n<p>  \u0421 \u044d\u0442\u0438\u043c \u043b\u0435\u0433\u043a\u043e \u0441\u043f\u0440\u0430\u0432\u0438\u043b\u0438\u0441\u044c. <\/p>\n<h3>\u0415\u0441\u043b\u0438 \u043c\u044b \u0437\u0430\u0445\u043e\u0442\u0438\u043c \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043d\u0435 \u0430\u043b\u0435\u0440\u0442, \u0430 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u043e\u043d\u043d\u0443\u044e \u0432\u044c\u044e\u0448\u043a\u0443 \u043f\u043e\u0441\u0440\u0435\u0434\u0438 \u044d\u043a\u0440\u0430\u043d\u0430?<\/h3>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/fg\/xr\/pq\/fgxrpqsgg_yqmy4txescavcvdvc.png\"><\/p>\n<p>  \u041f\u0430\u0440\u0443 \u043d\u043e\u0432\u044b\u0445 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u043e\u0432 \u043f\u043e \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0438 \u0440\u0435\u0448\u0430\u0442 \u043d\u0430\u0448\u0443 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443:<\/p>\n<pre><code class=\"swift\">protocol ErrorViewCreatable {     \tfunc createErrorView(for error: Error) -&gt; ErrorView     }          \/\/ MARK: - Default implementation     extension ErrorViewCreatable {     \tfunc createErrorView(for error: Error) -&gt; ErrorView {     \t\tif let recoverableError = error as? RecoverableError {     \t\t\treturn createRecoverableAlert(for: recoverableError)     \t\t}          \t\tlet defaultTitle = &quot;Error&quot;     \t\tlet description = errorReason(from: error)     \t\tif let localizedError = error as? LocalizedError {     \t\t\treturn createErrorView(     \t\t\t\ttitle: localizedError.errorDescription ?? defaultTitle,     \t\t\t\tmessage: description)     \t\t}     \t\treturn createErrorView(title: defaultTitle, message: description)     \t\t}          \tfileprivate func createErrorView(title: String?, message: String?, actions: [ErrorView.Action] = []) -&gt; ErrorView {     \t\t\/\/ \u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f ErrorView \u0432\u044b\u0448\u043b\u0430 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043e\u0431\u044a\u0435\u043c\u043d\u043e\u0439 \u0438 \u0441\u0438\u043b\u044c\u043d\u043e \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0434\u0438\u0437\u0430\u0439\u043d\u0430.                  \/\/ \u0412\u0430\u0440\u0438\u0430\u043d\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d \u043d\u0430 github     \t\treturn ErrorView(title: title, description: message, actions: actions)     \t}          \tfileprivate func createRecoverableAlert(for recoverableError: RecoverableError) -&gt; ErrorView {     \t\tlet title = recoverableError.errorDescription     \t\tlet message = errorReason(from: recoverableError)     \t\tlet actions = recoverableError.recoveryOptions.enumerated().map { (element) -&gt; ErrorView.Action in     \t\t\treturn ErrorView.Action(title: element.element) {     \t\t\t\trecoverableError.attemptRecovery(optionIndex: element.offset)     \t\t\t}     \t\t}     \t\treturn createErrorView(title: title, message: message, actions: actions)     \t}     }<\/code><\/pre>\n<pre><code class=\"swift\">protocol ErrorViewAddable: class {     \tfunc presentErrorView(from error: Error)          \tvar errorViewSuperview: UIView { get }     }          \/\/ MARK: - Default implementation     extension ErrorViewAddable where Self: ErrorViewCreatable {     \tfunc presentErrorView(from error: Error) {     \t\tlet errorView = createErrorView(for: error)     \t\terrorViewSuperview.addSubview(errorView)     \t\terrorView.center = errorViewSuperview.center     \t}     }               \/\/ \u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0442\u0430\u043a\u043e\u0439 \u0436\u0435          \/\/ MARK: - ErrorAlertCreatable     extension ViewController: ErrorViewCreatable { }          \/\/ MARK: - ErrorAlertPresentable     extension ViewController: ErrorViewAddable {     \tvar errorViewSuperview: UIView {     \t\treturn self     \t}     }<\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0438 \u0432 \u0432\u0438\u0434\u0435 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0439 \u0432\u044c\u044e. \u041f\u0440\u0438\u0447\u0435\u043c, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0440\u0435\u0448\u0430\u0442\u044c, \u043a\u0430\u043a \u0438\u0445 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0440\u0438 \u043f\u0435\u0440\u0432\u043e\u043c \u0437\u0430\u0445\u043e\u0434\u0435 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d \u0438 \u043e\u0448\u0438\u0431\u043a\u0435 \u2013 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u0432\u044c\u044e. \u0410 \u0435\u0441\u043b\u0438 \u044d\u043a\u0440\u0430\u043d \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u043b\u0441\u044f \u0443\u0441\u043f\u0435\u0448\u043d\u043e, \u043d\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d\u0435 \u0432\u0435\u0440\u043d\u0443\u043b\u043e \u043e\u0448\u0438\u0431\u043a\u0443 \u2013 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0430\u043b\u0435\u0440\u0442.<\/p>\n<h3>\u0415\u0441\u043b\u0438 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0432\u044c\u044e \u043d\u0435\u0442?<\/h3>\n<p>  \u0418\u043d\u043e\u0433\u0434\u0430 \u043d\u0443\u0436\u043d\u043e \u0431\u0440\u043e\u0441\u0438\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0443, \u043d\u043e \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0432\u044c\u044e \u043d\u0435\u0442. \u0418\u043b\u0438 \u043c\u044b \u043d\u0435 \u0437\u043d\u0430\u0435\u043c, \u043a\u0430\u043a\u043e\u0435 \u0432\u044c\u044e \u0441\u0435\u0439\u0447\u0430\u0441 \u0430\u043a\u0442\u0438\u0432\u043d\u043e, \u0438 \u0445\u043e\u0442\u0438\u043c \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0430\u043b\u0435\u0440\u0442 \u043f\u043e\u0432\u0435\u0440\u0445 \u0432\u0441\u0435\u0433\u043e. \u041a\u0430\u043a \u0440\u0435\u0448\u0430\u0442\u044c \u044d\u0442\u0443 \u0437\u0430\u0434\u0430\u0447\u0443?<\/p>\n<p>  \u041e\u0434\u0438\u043d \u0438\u0437 \u0441\u0430\u043c\u044b\u0445 \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 (\u043d\u0430 \u043c\u043e\u0439 \u0432\u0437\u0433\u043b\u044f\u0434) \u043f\u043e\u0441\u0442\u0443\u043f\u0438\u0442\u044c \u0442\u0430\u043a \u0436\u0435, \u043a\u0430\u043a Apple \u043f\u043e\u0441\u0442\u0443\u043f\u0430\u0435\u0442 \u0441 \u043a\u043b\u0430\u0432\u0438\u0430\u0442\u0443\u0440\u043e\u0439. \u0421\u043e\u0437\u0434\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0439 Window \u043f\u043e\u0432\u0435\u0440\u0445 \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u044d\u043a\u0440\u0430\u043d\u0430. \u0421\u0434\u0435\u043b\u0430\u0435\u043c \u044d\u0442\u043e:<\/p>\n<pre><code class=\"swift\">@UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate {  \t\/\/ \u0421\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u2013 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0434\u0435\u0448\u0435\u0432\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435.  \t\/\/ \u0411\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u043c \u0438 \u0447\u0438\u0441\u0442\u044b\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0434\u0435\u0440\u0436\u0430\u0442\u0435\u043b\u044f \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0430 \u0435\u0433\u043e \u0447\u0435\u0440\u0435\u0437 DI \tstatic private(set) var errorWindow: UIWindow = { \t\tlet alertWindow = UIWindow.init(frame: UIScreen.main.bounds) \t\talertWindow.backgroundColor = .clear  \t\t\/\/ \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c rootViewController, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0434\u0435\u043b\u0430\u0442\u044c present \u0434\u043b\u044f \u043d\u043e\u0432\u044b\u0439 viewController \t\tlet viewController = UIViewController() \t\tviewController.view.backgroundColor = .clear \t\talertWindow.rootViewController = viewController  \t\treturn alertWindow \t}()<\/code><\/pre>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043d\u043e\u0432\u044b\u0439 \u0430\u043b\u0435\u0440\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043f\u043e\u0432\u0435\u0440\u0445 \u0432\u0441\u0435\u0433\u043e:<\/p>\n<pre><code class=\"swift\">final class AboveAllAlertController: UIAlertController { \tvar alertWindow: UIWindow { \t\treturn AppDelegate.alertWindow \t}  \tfunc show() { \t\tlet topWindow = UIApplication.shared.windows.last \t\tif let topWindow = topWindow { \t\t\talertWindow.windowLevel = topWindow.windowLevel + 1 \t\t}  \t\talertWindow.makeKeyAndVisible() \t\talertWindow.rootViewController?.present(self, animated: true, completion: nil) \t}  \toverride func viewWillDisappear(_ animated: Bool) { \t\tsuper.viewWillDisappear(animated)  \t\talertWindow.isHidden = true \t} }<\/code><\/pre>\n<pre><code class=\"swift\">protocol ErrorAlertCreatable: class {     \t\/\/ \u0414\u043e\u0431\u0430\u0432\u0438\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f      \tfunc createAlert(for error: Error, aboveAll: Bool) -&gt; UIAlertController     }          \/\/ MARK: - Default implementation     extension ErrorAlertCreatable where Self: UIViewController {     \t...     \t\/\/ \u0418 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043d\u0430\u0448 \u043d\u043e\u0432\u044b\u0439 \u0430\u043b\u0435\u0440\u0442     \tfileprivate func createAlert(title: String?, message: String?, actions: [UIAlertAction], aboveAll: Bool) -&gt; UIAlertController {     \t\tlet alertViewController = aboveAll ?     \t\t\tAboveAllAlertController(title: title, message: message, preferredStyle: .alert) :     \t\t\tUIAlertController(title: title, message: message, preferredStyle: .alert)     \t\tactions.forEach({ alertViewController.addAction($0) })     \t\treturn alertViewController     \t}     }          \/\/ \u0418 \u043f\u0440\u043e \u043f\u043e\u043a\u0430\u0437 \u043d\u0435 \u0437\u0430\u0431\u0443\u0434\u0435\u043c     protocol ErrorAlertPresentable: class {     \tfunc presentAlert(from error: Error)     \tfunc presentAlertAboveAll(from error: Error)     }          \/\/ MARK: - Default implementation     extension ErrorAlertPresentable where Self: ErrorAlertCreatable &amp; UIViewController {     \tfunc presentAlert(from error: Error) {     \t\tlet alertVC = createAlert(for: error, aboveAll: false)     \t\tpresent(alertVC, animated: true, completion: nil)     \t}          \tfunc presentAlertAboveAll(from error: Error) {     \t\tlet alertVC = createAlert(for: error, aboveAll: true)     \t\t\/\/ \u041f\u0435\u0440\u0435\u0432\u0435\u0434\u0435\u043c \u0432 \u043d\u0443\u0436\u043d\u044b\u0439 \u0442\u0438\u043f \u0438 \u0432\u044b\u0437\u044b\u0432\u0435\u043c \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043f\u043e\u043a\u0430\u0437\u0430     \t\tif let alertVC = alertVC as? AboveAllAlertController {     \t\t\talertVC.show()     \t\t\treturn     \t\t}     \t\t\/\/ \u041f\u043e\u043c\u043e\u0436\u0435\u0442 \u043d\u0430\u043c \u043d\u0430\u0439\u0442\u0438 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443, \u0435\u0441\u043b\u0438 \u0447\u0442\u043e-\u0442\u043e \u043e\u0442\u043b\u043e\u043c\u0430\u0435\u0442\u0441\u044f     \t\tassert(false, &quot;Should create AboveAllAlertController&quot;)     \t\tpresent(alertVC, animated: true, completion: nil)     \t}     }<\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/qr\/es\/uo\/qresuobexdwaxevl3gnmsfjsc6i.png\"><\/p>\n<p>  \u0421 \u0432\u0438\u0434\u0443 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u043e\u0441\u044c, \u043d\u043e \u0442\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043e\u0442\u0432\u044f\u0437\u0430\u043b\u0438\u0441\u044c \u043e\u0442 \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u0438 view controller&#8217;\u043e\u0432. \u042f \u043d\u0430\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u043d\u0435 \u0443\u0432\u043b\u0435\u043a\u0430\u0442\u044c\u0441\u044f \u044d\u0442\u043e\u0439 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c\u044e. \u041b\u0443\u0447\u0448\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u043a\u043e\u0434 \u043f\u043e\u043a\u0430\u0437\u0430 \u0432 \u0440\u043e\u0443\u0442\u0435\u0440\u0435 \u0438\u043b\u0438 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u0441 \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u044b\u043c\u0438 \u043f\u0440\u0430\u0432\u0430\u043c\u0438. \u0412\u043e \u0438\u043c\u044f \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e\u0441\u0442\u0438 \u0438 \u043f\u043e\u043d\u044f\u0442\u043d\u043e\u0441\u0442\u0438. <\/p>\n<p>  \u041c\u044b \u0434\u0430\u043b\u0438 \u044e\u0437\u0435\u0440\u0430\u043c \u043f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u044b\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0434\u043b\u044f \u0441\u043f\u0430\u043c\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432 \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u043d\u0435\u043f\u043e\u043b\u0430\u0434\u043e\u043a, \u0442\u0435\u0445\u043e\u0431\u0441\u043b\u0443\u0436\u0438\u0432\u0430\u043d\u0438\u044f \u0438 \u0442.\u0434. \u0427\u0442\u043e \u043c\u043e\u0436\u0435\u043c \u0443\u043b\u0443\u0447\u0448\u0438\u0442\u044c?<\/p>\n<h3>\u041c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430<\/h3>\n<p>  \u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u043c\u044b \u0432\u044b\u043a\u043b\u044e\u0447\u0438\u043c \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442 \u0438 \u0431\u0443\u0434\u0435\u043c \u0436\u0430\u0442\u044c try again. \u0417\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u043b\u043e\u0443\u0434\u0435\u0440. \u041e\u0442\u0432\u0435\u0442 \u043f\u0440\u0438\u0434\u0451\u0442 \u043c\u043e\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u043e \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f \u043c\u0438\u043d\u0438-\u0438\u0433\u0440\u0430 \u00ab\u041a\u043b\u0438\u043a\u0435\u0440\u00bb. \u0421 \u043c\u0438\u0433\u0430\u044e\u0449\u0435\u0439 \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0435\u0439. \u041d\u0435 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043f\u0440\u0438\u044f\u0442\u043d\u043e.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/uz\/3n\/mu\/uz3nmu7_ag_k4swmsiy8gw2y1z0.gif\"><\/p>\n<p>  \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u043c \u043c\u043e\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u0443\u044e \u043e\u0448\u0438\u0431\u043a\u0443 \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441. \u0418\u0434\u0435\u044f \u043f\u0440\u043e\u0441\u0442\u0430 \u2013 \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430. \u0417\u0434\u0435\u0441\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0432\u0430\u0448\u0435\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430 \u043a networking. \u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e Operation, \u0438 \u0434\u043b\u044f \u043c\u0435\u043d\u044f \u044d\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"swift\">final class DelayOperation: AsyncOperation { \tprivate let _delayTime: Double  \tinit(delayTime: Double = 0.3) { \t\t_delayTime = delayTime \t} \toverride func main() { \t\tsuper.main()  \t\tDispatchQueue.global().asyncAfter(deadline: .now() + _delayTime) { \t\t\tself.state = .finished \t\t} \t} } \t\t \/\/ \u0413\u0434\u0435-\u0442\u043e \u0432 \u043a\u043e\u0434\u0435 let flowListOperation = flowService.list(for: pageID, path: path, limiter: limiter) let handler = createHandler(for: flowListOperation) let delayOperation = DelayOperation(delayTime: 0.5) \/\/\/ \u041f\u043e\u0434 &gt;&gt;&gt; \u043f\u0440\u044f\u0447\u0435\u0442\u0441\u044f addDependency.  [flowListOperation, delayOperation] &gt;&gt;&gt; handler operationQueue.addOperations([flowListOperation, delayOperation, handler])<\/code><\/pre>\n<p>  \u0414\u043b\u044f \u043e\u0431\u0449\u0435\u0433\u043e \u0441\u043b\u0443\u0447\u0430\u044f \u043c\u043e\u0433\u0443 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0438\u0442\u044c \u0442\u0430\u043a\u0443\u044e \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044e:  <\/p>\n<pre><code class=\"swift\">\/\/ \u0412\u043c\u0435\u0441\u0442\u043e global \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043b\u044e\u0431\u0443\u044e \u043d\u0443\u0436\u043d\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c  DispatchQueue.global().asyncAfter(deadline: .now() + 0.15) {     \/\/ your code here }<\/code><\/pre>\n<p>  \u0418\u043b\u0438 \u0436\u0435 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u044e \u043d\u0430\u0434 \u043d\u0430\u0448\u0438\u043c\u0438 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u043c\u0438 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f\u043c\u0438 \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0435\u0439 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c\u043e\u0441\u0442\u0438:<\/p>\n<pre><code class=\"swift\">struct Task {     \tlet closure: () -&gt; Void          \tprivate var _delayTime: Double?          \tinit(closure: @escaping () -&gt; Void) {     \t\tself.closure = closure     \t}          \tfileprivate init(closure: @escaping () -&gt; Void, time: Double) {     \t\tself.closure = closure     \t\t_delayTime = time     \t}          \t@discardableResult     \tfunc run() -&gt; Self {     \t\tif let delayTime = _delayTime {     \t\t\tDispatchQueue.global().asyncAfter(deadline: .now() + delayTime) {     \t\t\t\tself.closure()     \t\t\t}     \t\t\treturn self     \t\t}     \t\tclosure()     \t\treturn self     \t}          \tfunc delayedTask(time: Double) -&gt; Self {     \t\treturn Task(closure: closure, time: time)     \t}     }          \/\/ \u0413\u0434\u0435 \u0442\u043e \u0432\u043d\u0443\u0442\u0440\u0438 \u0441\u0435\u0440\u0432\u0438\u0441\u0430     func requestObject(completionHandler: @escaping ((Result&lt;Bool, Error&gt;) -&gt; Void)) -&gt; Task {     \t\treturn Task {     \t\t\tcompletionHandler(.failure(NetworkError.internetError))     \t\t}     \t\t\t.delayedTask(time: 0.5)     \t\t.run()     \t}<\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u0448\u0430 \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u044f \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u0442\u0430\u043a\u043e\u0439 \u0440\u0435\u0437\u043a\u043e\u0439, \u0434\u0430\u0436\u0435 \u043f\u0440\u0438 \u0440\u0435\u0436\u0438\u043c\u0435 \u043e\u0444\u043b\u0430\u0439\u043d. \u0420\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u0432 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0435 \u043c\u0435\u0441\u0442 \u0441 \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0435\u0439.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/9k\/oq\/46\/9koq46qq0wffoivy0ucs18om1cm.gif\"><\/p>\n<p>  \u0414\u043b\u044f \u0430\u0432\u0438\u0430\u0440\u0435\u0436\u0438\u043c\u0430 \u0445\u043e\u0440\u043e\u0448\u043e \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0430\u043b\u0435\u0440\u0442-\u043f\u043e\u0434\u0441\u043a\u0430\u0437\u043a\u0443 (\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043c\u043e\u0433 \u0437\u0430\u0431\u044b\u0442\u044c \u0432\u044b\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0440\u0435\u0436\u0438\u043c \u0434\u043b\u044f \u0441\u0442\u0430\u0440\u0442\u0430 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u043c). \u041a\u0430\u043a, \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u0434\u0435\u043b\u0430\u0435\u0442 \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c\u043c. \u0410 \u0434\u043b\u044f \u0432\u0430\u0436\u043d\u044b\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0445\u043e\u0440\u043e\u0448\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u043f\u043e\u0432\u0442\u043e\u0440 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437 \u043f\u043e\u0434 \u043a\u0430\u043f\u043e\u0442\u043e\u043c, \u043f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0430\u043b\u0435\u0440\u0442\u2026 \u041d\u043e \u043e\u0431 \u044d\u0442\u043e\u043c \u0432 \u0434\u0440\u0443\u0433\u043e\u0439 \u0440\u0430\u0437 \ud83d\ude42<\/p>\n<h3>\u0422\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c\u043e\u0441\u0442\u044c<\/h3>\n<p>  \u041a\u043e\u0433\u0434\u0430 \u0432\u0441\u044f \u043b\u043e\u0433\u0438\u043a\u0430 \u0441\u0432\u0430\u043b\u0435\u043d\u0430 \u0432\u043e viewController (\u043a\u0430\u043a \u0443 \u043d\u0430\u0441 \u0441\u0435\u0439\u0447\u0430\u0441), \u043f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e \u0437\u0430\u0442\u0440\u0443\u0434\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e. \u041e\u0434\u043d\u0430\u043a\u043e \u0435\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 viewController \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d \u0441 \u0431\u0438\u0437\u043d\u0435\u0441 \u043b\u043e\u0433\u0438\u043a\u043e\u0439 \u2013 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0442\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435\u0439. \u041b\u0435\u0433\u043a\u0438\u043c\u0438 \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u0435\u043c \u0440\u0443\u043a\u0438 <s>\u0431\u0440\u044e\u043a\u0438<\/s> \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0430 \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u0432:<\/p>\n<pre><code class=\"swift\">func requestFeed() { \t\tservice.requestObject { [weak self] (result) in \t\t\tguard let `self` = self else { return } \t\t\tswitch result { \t\t\tcase .success: \t\t\t\tbreak \t\t\tcase .failure(let error): \t\t\t\tDispatchQueue.main.async { \t\t\t\t\tlet recoverableError = RecoverableError(error: error, attempter: .tryAgainAttempter(block: { \t\t\t\t\t\tself.requestFeed() \t\t\t\t\t})) \t\t\t\t\t\/\/ \u0414\u0435\u043b\u0435\u0433\u0438\u0440\u0443\u0435\u043c \u0434\u0440\u0443\u0433\u043e\u043c\u0443 \u043e\u0431\u044a\u0435\u043a\u0442\u0443 \u043f\u043e\u043a\u0430\u0437 \u0430\u043b\u0435\u0440\u0442\u0430 \t\t\t\t\tself.viewInput?.presentAlert(from: recoverableError) \t\t\t\t} \t\t\t} \t\t} \t}<\/code><\/pre>\n<pre><code class=\"swift\">\/\/ \u0413\u0434\u0435-\u0442\u043e \u0432 \u0442\u0435\u0441\u0442\u0430\u0445 func testRequestFeedFailed() { \t\/\/ Put out mock that conform to AlertPresntable protocol \tcontroller.viewInput = ViewInputMock()  \t\/\/ \u0412\u044b\u0437\u043e\u0432\u0435\u043c \u043c\u0435\u0442\u043e\u0434. \u041d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u0434\u043e\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043d\u0435\u0442\u0432\u043e\u0440\u043a\u0438\u043d\u0433, \u0447\u0442\u043e\u0431\u044b \u043e\u043d \u0440\u0430\u0431\u043e\u0442\u0430\u043b \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e \t\/\/ \u0418\u043b\u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043f\u043e\u0441\u043b\u0435 expectation \tcontroller.requestFeed()  \t\/\/ Our mocked object should save to true to bool variable when method called \tXCTAssert(controller.viewInput.presentAlertCalled) \t\/\/ Next we could compare recoverable error attempter to expected attempter }<\/code><\/pre>\n<p>  \u0412\u043c\u0435\u0441\u0442\u0435 \u0441 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435\u0439 \u043c\u044b:  <\/p>\n<ul>\n<li>\u0421\u0434\u0435\u043b\u0430\u043b\u0438 \u0443\u0434\u043e\u0431\u043d\u044b\u0439 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0430\u043b\u0435\u0440\u0442\u043e\u0432<\/li>\n<li>\u0414\u0430\u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u043e\u0432\u0442\u043e\u0440\u0438\u0442\u044c \u043d\u0435\u0443\u0441\u043f\u0435\u0448\u043d\u0443\u044e \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e<\/li>\n<li>\u0418 \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u043b\u0438\u0441\u044c \u0443\u043b\u0443\u0447\u0448\u0438\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u043e\u043f\u044b\u0442 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043d\u0430\u0448\u0438\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u043c<\/li>\n<\/ul>\n<p>  <a href=\"https:\/\/github.com\/aleksiosdev\/RecoverableError.git\">\u0421\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043a\u043e\u0434<\/a>. <\/p>\n<p>  \u0412\u0441\u0435\u043c \u0441\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u0443\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f, \u0431\u0443\u0434\u0443 \u0440\u0430\u0434 \u043e\u0442\u0432\u0435\u0442\u0438\u0442\u044c \u043d\u0430 \u0432\u0430\u0448\u0438 \u0432\u043e\u043f\u0440\u043e\u0441\u044b \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445.<\/p><\/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\/company\/manychat\/blog\/495346\/\"> https:\/\/habr.com\/ru\/company\/manychat\/blog\/495346\/<\/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\/company\/manychat\/blog\/495346\/\">\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440! \u0414\u043b\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u043e\u0431 \u043e\u0448\u0438\u0431\u043a\u0435 \u0447\u0430\u0441\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u044f\u0442 \u043a\u0430\u043a \u00ab\u0427\u0442\u043e-\u0442\u043e \u043d\u0435 \u0442\u0430\u043a, \u0410\u0410\u0410\u0410!\u00bb. \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u0435\u043c\u0443 \u0431\u044b \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0432\u043c\u0435\u0441\u0442\u043e \u043e\u0448\u0438\u0431\u043e\u043a \u0432\u0438\u0434\u0435\u0442\u044c \u0432\u043e\u043b\u0448\u0435\u0431\u043d\u0443\u044e \u043e\u0448\u0438\u0431\u043a\u0443 \u00ab\u041f\u043e\u0447\u0438\u043d\u0438\u0442\u044c \u0432\u0441\u0435\u00bb. \u041d\u0443 \u0438\u043b\u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439. \u041c\u044b \u043d\u0430\u0447\u0430\u043b\u0438 \u0430\u043a\u0442\u0438\u0432\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0441\u0435\u0431\u0435 \u0442\u0430\u043a\u0438\u0435, \u0438 \u044f \u0445\u043e\u0447\u0443 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c \u043f\u0440\u043e \u0442\u043e, \u043a\u0430\u043a \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c. <\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/6q\/cf\/s3\/6qcfs3uiu0o9ajdlcfi8frjb5pg.jpeg\"><\/p>\n<p>  \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044e\u0441\u044c \u2014 \u043c\u0435\u043d\u044f \u0437\u043e\u0432\u0443\u0442 \u0410\u043b\u0435\u043a\u0441\u0430\u043d\u0434\u0440, \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0435 \u0448\u0435\u0441\u0442\u044c \u043b\u0435\u0442 \u044f \u043f\u043e\u0441\u0432\u044f\u0442\u0438\u043b iOS-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435. \u0421\u0435\u0439\u0447\u0430\u0441 \u043e\u0442\u0432\u0435\u0447\u0430\u044e \u0437\u0430 \u043c\u043e\u0431\u0438\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 ManyChat \u0438 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0431\u0443\u0434\u0443 \u0440\u0435\u0448\u0430\u0442\u044c \u043d\u0430 \u0435\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0435. <\/p>\n<p>  \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u0440\u0430\u0437\u0443 \u0441\u0444\u043e\u0440\u043c\u0443\u043b\u0438\u0440\u0443\u0435\u043c, \u0447\u0442\u043e \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0434\u0435\u043b\u0430\u0442\u044c:<\/p>\n<ul>\n<li>\u0414\u043e\u0431\u0430\u0432\u0438\u043c \u0442\u0438\u043f\u0443 Error \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438<\/li>\n<li>\u041f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u043c \u043e\u0448\u0438\u0431\u043a\u0438 \u0432 \u043f\u043e\u043d\u044f\u0442\u043d\u044b\u0435 \u0434\u043b\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0430\u043b\u0435\u0440\u0442\u044b<\/li>\n<li>\u0412\u044b\u0432\u0435\u0434\u0435\u043c \u0432 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0435 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0438\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u0438\u0445 \u043d\u0430\u0436\u0430\u0442\u0438\u044f<\/li>\n<\/ul>\n<p>  \u0418 \u0432\u0441\u0435 \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u043d\u0430 Swift:)<\/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-301344","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/301344","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=301344"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/301344\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=301344"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=301344"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=301344"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}