{"id":304501,"date":"2020-05-29T15:00:27","date_gmt":"2020-05-29T15:00:27","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=304501"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=304501","title":{"rendered":"\u041a\u0430\u043a \u043c\u044b \u043f\u0440\u0438\u0434\u0443\u043c\u0430\u043b\u0438 TableAdapter \u0438 \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u043b\u0438 \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 UITableView"},"content":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/504464\/\">\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/q8\/-l\/xp\/q8-lxpaxgl4muu9wok1htffafbg.png\"\/><\/p>\n<p>  <\/p>\n<p>\u041f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 <code>UITableView<\/code> \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0435\u0449\u0435 \u0431\u043e\u043b\u044c\u0448\u0435 \u0443\u0441\u043b\u043e\u0436\u043d\u044f\u0435\u0442\u0441\u044f, \u0435\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u043e \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0442\u044c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0430\u043d\u0438\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u043e. Apple \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043b\u0430 \u0441\u0432\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u044d\u0442\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u043d\u0430 WWDC 2019, \u043d\u043e \u043e\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0441 iOS 13. \u0410 \u0443 \u043d\u0430\u0441, \u043a\u0430\u043a \u0443 \u0441\u0442\u0443\u0434\u0438\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043c\u043e\u0431\u0438\u043b\u044c\u043d\u044b\u0439 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439, \u043d\u0435\u0442 \u0442\u0430\u043a\u043e\u0439 \u0440\u043e\u0441\u043a\u043e\u0448\u0438 \u0432 \u0432\u044b\u0431\u043e\u0440\u0435 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 iOS.<\/p>\n<p>  <\/p>\n<p>\u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043b\u0438 \u043d\u0430\u0448\u0435 \u0432\u0438\u0434\u0435\u043d\u0438\u0435 data-driven \u043f\u043e\u0434\u0445\u043e\u0434\u0430 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u043c\u0438, \u043f\u043e\u043f\u0443\u0442\u043d\u043e \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0432 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0443 \u044f\u0447\u0435\u0435\u043a. \u0418 \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 \u0430\u043d\u0438\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u043e \u043d\u0430 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u043c \u043f\u043e\u0434\u0441\u0447\u0435\u0442\u0435 \u0440\u0430\u0437\u043b\u0438\u0447\u0438\u0439 \u043c\u0435\u0436\u0434\u0443 \u0441\u0442\u0430\u0440\u044b\u043c\u0438 \u0438 \u043d\u043e\u0432\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0437\u0430 \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f <strong>O(n)<\/strong>. \u0412\u0441\u0435 \u044d\u0442\u043e \u043c\u044b \u043e\u0444\u043e\u0440\u043c\u0438\u043b\u0438 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0443\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043d\u0430\u0437\u0432\u0430\u043b\u0438 TableAdapter.<\/p>\n<p>  <\/p>\n<p>\u041e \u0442\u043e\u043c, \u0447\u0442\u043e \u0443 \u043d\u0430\u0441 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u0438 \u043a\u0430\u043a \u043c\u044b \u043a \u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0438\u0448\u043b\u0438, \u0438 \u043f\u043e\u0439\u0434\u0435\u0442 \u0440\u0435\u0447\u044c \u0432 \u0441\u0442\u0430\u0442\u044c\u0435.<\/p>\n<p><a name=\"habracut\"><\/a>  <\/p>\n<h2 id=\"plyusy-i-minusy-tableadapter\">\u041f\u043b\u044e\u0441\u044b \u0438 \u043c\u0438\u043d\u0443\u0441\u044b TableAdapter<\/h2>\n<p>  <\/p>\n<h3 id=\"plyusy\">\u041f\u043b\u044e\u0441\u044b<\/h3>\n<p>  <\/p>\n<ul>\n<li>\u041e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0441 \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u044f\u043c\u0438<\/li>\n<li>\u0410\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u0440\u0430\u0437\u043d\u043e\u0441\u0442\u0438 \u0437\u0430 \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f<\/li>\n<li>\u041d\u0435 \u043d\u0443\u0436\u043d\u043e \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c \u0442\u0430\u0431\u043b\u0438\u0446\u0443, \u044f\u0447\u0435\u0439\u043a\u0443 \u0438\u043b\u0438 \u043c\u043e\u0434\u0435\u043b\u044c<\/li>\n<li>\u041d\u0438\u043a\u0430\u043a\u0438\u0445 \u0431\u043e\u043b\u044c\u0448\u0435 <code>dequeReusable...<\/code><\/li>\n<li>\u0422\u0438\u043f\u043e\u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u0430\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u044f\u0447\u0435\u0435\u043a, \u0445\u0435\u0434\u0435\u0440\u0430\/\u0444\u0443\u0442\u0435\u0440\u0430<\/li>\n<li>\u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u044f\u0447\u0435\u0439\u043a\u0438 \u043b\u044e\u0431\u044b\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c<\/li>\n<li>\u041f\u0440\u043e\u0441\u0442\u0430\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0441\u0435\u043a\u0446\u0438\u0439<\/li>\n<li>\u041b\u0435\u0433\u043a\u0430 \u0432 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0438<\/li>\n<\/ul>\n<p>  <\/p>\n<h3 id=\"minusy\">\u041c\u0438\u043d\u0443\u0441\u044b<\/h3>\n<p>  <\/p>\n<p>\u0417\u0430 \u0432\u0441\u0435 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u043b\u0430\u0442\u0438\u0442\u044c, \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044d\u0442\u043e \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u043d\u0430 \u043c\u043e\u0434\u0435\u043b\u044c \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0432\u0438\u0434\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430 <code>Hashable<\/code>. \u0427\u0442\u043e, \u0432 \u043e\u0431\u0449\u0435\u043c-\u0442\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0432 \u044f\u0437\u044b\u043a\u0435 Swift, \u0442.\u043a. \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u0431\u0430\u0437\u043e\u0432\u044b\u0445 \u0442\u0438\u043f\u043e\u0432 \u0443\u0436\u0435 \u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u044f\u0435\u0442 \u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0443. \u0418 \u0434\u043b\u044f \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0442\u0438\u043f\u043e\u0432 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u0435\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u0430 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043f\u043e \u043a\u0430\u043a\u043e\u043c\u0443-\u043b\u0438\u0431\u043e \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0443.<\/p>\n<p>  <\/p>\n<h2 id=\"primery\">\u041f\u0440\u0438\u043c\u0435\u0440\u044b<\/h2>\n<p>  <\/p>\n<div class=\"scrollable-table\">\n<table>\n<tr>\n<th><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/fj\/qb\/-u\/fjqb-u-u2fknryani5u389yff4s.gif\"\/><\/th>\n<th><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/k9\/yp\/js\/k9ypjsztfjtb2nbxbeypsxj0sqw.gif\"\/><\/th>\n<th><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/il\/yc\/fn\/ilycfn6webhwmaw8ynkszssiq1e.gif\"\/><\/th>\n<\/tr>\n<\/table>\n<\/div>\n<p>  <\/p>\n<h2 id=\"ispolzovanie\">\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435<\/h2>\n<p>  <\/p>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u2013 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0442\u0440\u0435\u0445\u0448\u0430\u0433\u043e\u0432\u044b\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441:<\/p>\n<p>  <\/p>\n<h3 id=\"1-podgotovka-modeley-yacheek-i-hederovfuterov\">1. \u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430 \u043c\u043e\u0434\u0435\u043b\u0435\u0439, \u044f\u0447\u0435\u0435\u043a \u0438 \u0445\u0435\u0434\u0435\u0440\u043e\u0432\/\u0444\u0443\u0442\u0435\u0440\u043e\u0432<\/h3>\n<p>  <\/p>\n<h4 id=\"11-podgotovka-modeli\">1.1 \u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430 \u043c\u043e\u0434\u0435\u043b\u0438<\/h4>\n<p>  <\/p>\n<p>\u041c\u043e\u0434\u0435\u043b\u044c, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u0430 \u0432 \u044f\u0447\u0435\u0439\u043a\u0443, \u0434\u043e\u043b\u0436\u043d\u0430 \u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u044f\u0442\u044c \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0443 <code>Hashable<\/code>.<\/p>\n<p>  <\/p>\n<pre><code class=\"swift\">extension User: Hashable { ... }<\/code><\/pre>\n<p>  <\/p>\n<h4 id=\"12-podgotovka-yacheyki\">1.2 \u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430 \u044f\u0447\u0435\u0439\u043a\u0438<\/h4>\n<p>  <\/p>\n<p>\u042f\u0447\u0435\u0439\u043a\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b <code>Configurable<\/code>, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u044c. \u042d\u0442\u043e \u0434\u0436\u0435\u043d\u0435\u0440\u0438\u043a \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b, \u0442\u0430\u043a \u0447\u0442\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0432\u044b\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0439 \u0442\u0438\u043f \u043c\u043e\u0434\u0435\u043b\u0438.<\/p>\n<p>  <\/p>\n<pre><code class=\"swift\">extension Cell: Configurable {      public func setup(with item: User) {         textLabel?.text = item.name     } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412 \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0441\u043b\u0438 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0439 \u0442\u0438\u043f \u043c\u043e\u0434\u0435\u043b\u0438 \u043d\u0435 \u0441\u043e\u0432\u043f\u0430\u0434\u0451\u0442 \u0441 \u0442\u0435\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u043d, \u0442\u043e <strong>\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0435 \u0443\u043f\u0430\u0434\u0435\u0442<\/strong>. \u0412 \u043a\u043e\u043d\u0441\u043e\u043b\u044c \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043e \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043e \u043d\u0435\u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 \u0442\u0438\u043f\u043e\u0432, \u0430 \u043c\u0435\u0442\u043e\u0434 <code>setup(with:)<\/code> \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0437\u0432\u0430\u043d \u0443 \u044f\u0447\u0435\u0439\u043a\u0438.<\/p>\n<p>  <\/p>\n<h4 id=\"13-podgotovka-hederafutera\">1.3 \u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430 \u0445\u0435\u0434\u0435\u0440\u0430\/\u0444\u0443\u0442\u0435\u0440\u0430<\/h4>\n<p>  <\/p>\n<p>\u041a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0439 \u0445\u0435\u0434\u0435\u0440\/\u0444\u0443\u0442\u0435\u0440 \u0442\u0430\u043a\u0436\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b <code>Configurable<\/code>, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u0432\u043e\u044e \u043c\u043e\u0434\u0435\u043b\u044c \u0434\u043b\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438. \u0414\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0434\u0435\u0444\u043e\u043b\u0442\u043d\u043e\u0433\u043e \u0445\u0435\u0434\u0435\u0440\u0430\/\u0444\u0443\u0442\u0435\u0440\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0448\u0430\u0433 1.3 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u0442\u044c.<\/p>\n<p>  <\/p>\n<h3 id=\"2-sozdanie-sekciy\">2. \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0441\u0435\u043a\u0446\u0438\u0439<\/h3>\n<p>  <\/p>\n<p>\u0421\u0435\u043a\u0446\u0438\u044f \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0445 (\u043c\u043e\u0434\u0435\u043b\u044f\u0445) \u0434\u043b\u044f \u044f\u0447\u0435\u0435\u043a \u0432 \u044d\u0442\u043e\u0439 \u0441\u0435\u043a\u0446\u0438\u0438, \u0445\u0435\u0434\u0435\u0440\u0435\/\u0444\u0443\u0442\u0435\u0440\u0435. \u041e\u043d\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0434\u0436\u0435\u043d\u0435\u0440\u0438\u043a \u0442\u0438\u043f\u043e\u043c <code>Section&lt;Item, SectionId&gt;<\/code>, \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043d\u0443\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0442\u0438\u043f \u043c\u043e\u0434\u0435\u043b\u0438 (<code>Item<\/code>) \u0438 \u0442\u0438\u043f \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u0430 \u0441\u0435\u043a\u0446\u0438\u0438 (<code>SectionId<\/code>). \u0418\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 (<strong>id<\/strong>) \u0442\u0430\u043a\u0436\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b <code>Hashable<\/code>, \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0434\u043b\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043f\u043e\u0434\u0441\u0447\u0435\u0442\u0430 \u0440\u0430\u0437\u043b\u0438\u0447\u0438\u0439 \u043c\u0435\u0436\u0434\u0443 \u0441\u0442\u0430\u0440\u044b\u043c\u0438 \u0438 \u043d\u043e\u0432\u044b\u043c\u0438 \u0441\u0435\u043a\u0446\u0438\u044f\u043c\u0438.<\/p>\n<p>  <\/p>\n<h4 id=\"defoltnyy-hederfuter\">\u0414\u0435\u0444\u043e\u043b\u0442\u043d\u044b\u0439 \u0445\u0435\u0434\u0435\u0440\/\u0444\u0443\u0442\u0435\u0440<\/h4>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0434\u0435\u0444\u043e\u043b\u0442\u043d\u043e\u0433\u043e \u0445\u0435\u0434\u0435\u0440\u0430\/\u0444\u0443\u0442\u0435\u0440\u0430 \u0441\u0435\u043a\u0446\u0438\u0438 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u043d\u0443\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0441\u0442\u0440\u043e\u043a\u0443 \u043f\u043e \u043a\u043b\u044e\u0447\u0443 <code>header<\/code>\/<code>footer<\/code>.<\/p>\n<p>  <\/p>\n<h4 id=\"kastomnyy-hederfuter\">\u041a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0439 \u0445\u0435\u0434\u0435\u0440\/\u0444\u0443\u0442\u0435\u0440<\/h4>\n<p>  <\/p>\n<p>\u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u043e\u0433\u043e \u0445\u0435\u0434\u0435\u0440\u0430\/\u0444\u0443\u0442\u0435\u0440\u0430 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u043d\u0443\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 <code>headerIdentifier<\/code>\/<code>footerIdentifier<\/code>, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u043e\u043d \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f. \u0410 \u0442\u0438\u043f \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0435\u043c\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 \u0434\u043b\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0434\u043e\u043b\u0436\u0435\u043d \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0442\u0438\u043f\u0443, \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u043c\u0443 \u043f\u0440\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430 <code>Configurable<\/code> (\u0428\u0430\u0433 1.3).<\/p>\n<p>  <\/p>\n<pre><code class=\"swift\">let section = Section&lt;User, Int&gt;(     id: 0,     items: users,     header: &quot;Users Section&quot;,     footer: &quot;Users Section&quot;,     headerIdentifier: &quot;HeaderReuseIdentifier&quot;,     footerIdentifier: &quot;FooterReuseIdentifier&quot; )<\/code><\/pre>\n<p>  <\/p>\n<blockquote><p>\u041d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u0443\u0434\u043e\u0431\u043d\u043e \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 <code>id<\/code> \u0441\u0435\u043a\u0446\u0438\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u043d\u0430\u043c\u044b.<\/p><\/blockquote>\n<p>  <\/p>\n<h3 id=\"3-sozdanie-adaptera\">3. \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u0430<\/h3>\n<p>  <\/p>\n<p>\u0410\u0434\u0430\u043f\u0442\u0435\u0440 \u0442\u0430\u043a\u0436\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0434\u0436\u0435\u043d\u0435\u0440\u0438\u043a \u0442\u0438\u043f\u043e\u043c <code>TableAdapter&lt;Item, SectionId&gt;<\/code>, \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0442\u0430\u043a\u0436\u0435 \u043d\u0443\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0442\u0438\u043f \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u0432 \u0441\u0435\u043a\u0446\u0438\u044f\u0445 (<code>Item<\/code>) \u0438 \u0442\u0438\u043f \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u0430 \u0441\u0435\u043a\u0446\u0438\u0439 (<code>SectionId<\/code>). \u042d\u0442\u0438 \u0442\u0438\u043f\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u0442\u044c \u0441 \u0442\u0438\u043f\u0430\u043c\u0438, \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u043c\u0438 \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u0441\u0435\u043a\u0446\u0438\u0438.<\/p>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0440\u0430\u0437\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432 \u044f\u0447\u0435\u0435\u043a \u043d\u0443\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0437\u0430\u043c\u044b\u043a\u0430\u043d\u0438\u0435 <code>CellReuseIdentifierProvider<\/code>, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u044f\u0447\u0435\u0439\u043a\u0438. \u0414\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430, \u0432 \u044d\u0442\u043e \u0437\u0430\u043c\u044b\u043a\u0430\u043d\u0438\u0435 \u0441\u0440\u0430\u0437\u0443 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f IndexPath \u0438 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0430\u044f \u0435\u043c\u0443 \u043c\u043e\u0434\u0435\u043b\u044c \u0441 \u0442\u0438\u043f\u043e\u043c, \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u043c \u0440\u0430\u043d\u0435\u0435.<\/p>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043d\u0430\u0436\u0430\u0442\u0438\u044f \u043d\u0430 \u044f\u0447\u0435\u0439\u043a\u0443 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043e \u0437\u0430\u043c\u044b\u043a\u0430\u043d\u0438\u0435 <code>\u0421ellDidSelectHandler<\/code>, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0430, IndexPath \u0438 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0430\u044f \u0435\u043c\u0443 \u043c\u043e\u0434\u0435\u043b\u044c.<\/p>\n<p>  <\/p>\n<pre><code class=\"swift\">lazy var adapter = TableAdapter&lt;User, Int&gt;(     tableView: tableView,     cellIdentifierProvider: { (indexPath, item) -&gt; String? in         \/\/ Return cell reuse identifier for item at indexPath     },     cellDidSelectHandler: { [weak self] (table, indexPath, item) in         \/\/ Handle cell selection for item at indexPath     } )<\/code><\/pre>\n<p>  <\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0430\u0434\u0430\u043f\u0442\u0435\u0440 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0440\u0430\u043d\u0435\u0435 \u0441\u0435\u043a\u0446\u0438\u044f\u043c\u0438:<\/p>\n<p>  <\/p>\n<pre><code class=\"swift\">adapter.update(with: [section], animated: true)<\/code><\/pre>\n<p>  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u041a\u043e\u0434 \u0446\u0435\u043b\u0438\u043a\u043e\u043c<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"swift\">class ViewController: UIViewController {      let tableView = ...      lazy var adapter = TableAdapter&lt;User, Int&gt;(         tableView: tableView,         cellIdentifierProvider: { (indexPath, item) -&gt; String? in             return &quot;CellReuseIdentifier&quot;         },         cellDidSelectHandler: { [weak self] (table, indexPath, item) in             \/\/ Handle cell selection for item at indexPath         }     )      let users: [User] = [...]      override func viewDidLoad() {         super.viewDidLoad()          setupTable()          let section = Section&lt;User, Int&gt;(             id: 0,             items: users,             header: &quot;Users Section&quot;,             footer: &quot;Users Section&quot;,             headerIdentifier: &quot;HeaderReuseIdentifier&quot;,             footerIdentifier: &quot;FooterReuseIdentifier&quot;         )          adapter.update(with: [section]], animated: true)     }      func setupTable() {         tableView.register(             Cell.self,             forCellReuseIdentifier: &quot;CellReuseIdentifier&quot;         )          tableView.register(             Header.self,             forHeaderFooterViewReuseIdentifier identifier: &quot;HeaderReuseIdentifier&quot;         )         tableView.register(             Footer.self,             forHeaderFooterViewReuseIdentifier identifier: &quot;FooterReuseIdentifier&quot;         )     } }<\/code><\/pre>\n<\/div><\/div>\n<p>  <\/p>\n<blockquote><p>\u041f\u0440\u043e\u0442\u043e\u043a\u043e\u043b <code>Hashable<\/code> \u043d\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0433\u0435\u0442\u0435\u0440\u043e\u0433\u0435\u043d\u043d\u044b\u0435 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u0438\u0445 \u043c\u043e\u0436\u043d\u043e \u043e\u0431\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0442\u044c \u0432 \u0435\u043d\u0430\u043c \u0441\u043e \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c (<em>associated value<\/em>).<\/p><\/blockquote>\n<p>  <\/p>\n<h2 id=\"chastnye-sluchai\">\u0427\u0430\u0441\u0442\u043d\u044b\u0435 \u0441\u043b\u0443\u0447\u0430\u0438<\/h2>\n<p>  <\/p>\n<h3 id=\"odin-tip-yacheek\">\u041e\u0434\u0438\u043d \u0442\u0438\u043f \u044f\u0447\u0435\u0435\u043a<\/h3>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432\u0441\u0435\u0433\u043e \u043e\u0434\u0438\u043d \u0442\u0438\u043f \u044f\u0447\u0435\u0435\u043a, \u0442\u043e \u0432 \u0430\u0434\u0430\u043f\u0442\u0435\u0440 \u043c\u043e\u0436\u043d\u043e \u043d\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0437\u0430\u043c\u044b\u043a\u0430\u043d\u0438\u0435 <code>CellReuserIdentifierProvider<\/code>. A \u044f\u0447\u0435\u0439\u043a\u0443 \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043e \u0434\u0435\u0444\u043e\u043b\u0442\u043d\u043e\u043c\u0443 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u0443 \u044f\u0447\u0435\u0435\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 &quot;Cell&quot; \u043f\u043e\u0434 \u043a\u0430\u043f\u043e\u0442\u043e\u043c:<\/p>\n<p>  <\/p>\n<pre><code class=\"swift\">tableView.register(     Cell.self,     forCellReuseIdentifier: adapter.defaultCellIdentifier )<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"odinakovyy-hederfuter-dlya-vseh-sekciy\">\u041e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0439 \u0445\u0435\u0434\u0435\u0440\/\u0444\u0443\u0442\u0435\u0440 \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u0441\u0435\u043a\u0446\u0438\u0439<\/h3>\n<p>  <\/p>\n<p>\u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u043e\u0436\u043d\u043e \u043d\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c <code>headerIdentifier<\/code>\/<code>footerIdentifier<\/code> \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u0441\u0435\u043a\u0446\u0438\u0438. \u0410 \u0445\u0435\u0434\u0435\u0440\/\u0444\u0443\u0442\u0435\u0440 \u0432\u044c\u044e \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043e \u0434\u0435\u0444\u043e\u043b\u0442\u043d\u043e\u043c\u0443 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u0443, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0434 \u043a\u0430\u043f\u043e\u0442\u043e\u043c <code>&quot;Header&quot;<\/code>\/<code>&quot;Footer&quot;<\/code>.<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">tableView.register(     HeaderView.self,     forHeaderFooterViewReuseIdentifier identifier: adapter.defaultHeaderIdentifier ) tableView.register(     FooterView.self,     forHeaderFooterViewReuseIdentifier identifier: adapter.defaultFooterIdentifier )<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"sender\">Sender<\/h3>\n<p>  <\/p>\n<p>\u041d\u0430 \u0441\u043b\u0443\u0447\u0430\u0439, \u0435\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u0441\u0442\u0430\u0432\u0438\u0442\u044c, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u0435\u043b\u0435\u0433\u0430\u0442, \u0443 \u044f\u0447\u0435\u0435\u043a \u0443 TableAdapter&#8217;a \u0435\u0441\u0442\u044c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e <code>sender<\/code>. \u041e\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043e \u0432 \u044f\u0447\u0435\u0439\u043a\u0443, \u0445\u0435\u0434\u0435\u0440\/\u0444\u0443\u0442\u0435\u0440 \u043f\u0440\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430 <code>SenderConfigurable<\/code>.<\/p>\n<p>  <\/p>\n<pre><code class=\"swift\"> class ViewController: UIViewController {      lazy var adapter = TableAdapter&lt;User, Int&gt;(         tableView: tableView,         sender: self     ) }  extension Cell: SenderConfigurable {      func setup(with item: User, sender: ViewController) {         textLabel?.text = item.name         delegate = sender     } }<\/code><\/pre>\n<p>  <\/p>\n<p><strong>\u0417\u0430\u043c\u0435\u0447\u0430\u043d\u0438\u0435:<\/strong> \u0435\u0441\u043b\u0438 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0439 \u0442\u0438\u043f \u043c\u043e\u0434\u0435\u043b\u0438 \u0438\u043b\u0438 \u0441\u0435\u043d\u0434\u0435\u0440\u0430 \u043d\u0435 \u0441\u043e\u0432\u043f\u0430\u0434\u0451\u0442 \u0441 \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u044b\u043c\u0438, \u0442\u043e <strong>\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0435 \u0443\u043f\u0430\u0434\u0435\u0442<\/strong>. \u0412 \u043a\u043e\u043d\u0441\u043e\u043b\u044c \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043e \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043e \u043d\u0435\u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 \u0442\u0438\u043f\u043e\u0432, \u0430 \u043c\u0435\u0442\u043e\u0434 <code>setup(with:sender:)<\/code> \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0437\u0432\u0430\u043d.<\/p>\n<p>  <\/p>\n<h3 id=\"nizkourovnevaya-nastroyka\">\u041d\u0438\u0437\u043a\u043e\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u0430\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430<\/h3>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0431\u043e\u043b\u0435\u0435 \u0442\u043e\u043d\u043a\u0430\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u044f\u0447\u0435\u0435\u043a, \u0442\u043e \u0430\u0434\u0430\u043f\u0442\u0435\u0440 \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441 \u0437\u0430\u043c\u044b\u043a\u0430\u043d\u0438\u0435\u043c <code>CellProvider<\/code>, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u044f\u0447\u0435\u0439\u043a\u0443 \u0434\u043b\u044f \u043c\u043e\u0434\u0435\u043b\u0438:<\/p>\n<p>  <\/p>\n<pre><code class=\"swift\">lazy var adapter = TableAdapter&lt;User, Int&gt;(     tableView: tableView,     cellProvider: { (table, indexPath, user) in         let cell = table.dequeueReusableCell(             withIdentifier: &quot;CellReuseIdentifier&quot;,             for: indexPath         ) as! Cell          cell.setup(with: user)          return cell     } )<\/code><\/pre>\n<p>  <\/p>\n<blockquote><p>\u0414\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0434\u0440\u0443\u0433\u0438\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0434\u0430\u0442\u0430\u0441\u043e\u0440\u0441\u0430\/\u0434\u0435\u043b\u0435\u0433\u0430\u0442\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0438\u043b\u0438 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u0430 <code>TableAdapter<\/code> \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d.<\/p><\/blockquote>\n<p>  <\/p>\n<h2 id=\"realizaciya\">\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f<\/h2>\n<p>  <\/p>\n<h3 id=\"obnovlenie-tablicy-s-animaciyami\">\u041e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0441 \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u044f\u043c\u0438<\/h3>\n<p>  <\/p>\n<p>\u0410\u043d\u0438\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u043e \u043d\u0430 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u043c \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0438 \u0440\u0430\u0437\u043b\u0438\u0447\u0438\u0439 (<em>diff<\/em>) \u043c\u0435\u0436\u0434\u0443 \u0441\u0442\u0430\u0440\u044b\u043c\u0438 \u0438 \u043d\u043e\u0432\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0432 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u0445 <strong>\u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0439<\/strong>, <strong>\u0432\u0441\u0442\u0430\u0432\u043e\u043a<\/strong> \u0438 <strong>\u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u0439<\/strong> \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432. \u0414\u043b\u044f \u0438\u0445 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u041f\u043e\u043b\u0430 \u0425\u0435\u043a\u043a\u0435\u043b\u044f, \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 \u0432 \u0441\u0442\u0430\u0442\u044c\u0435 <a href=\"https:\/\/dl.acm.org\/doi\/10.1145\/359460.359467\">A technique for isolating differences between files<\/a>. \u041e\u043d \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u0442\u044c \u043d\u0443\u0436\u043d\u044b\u0435 \u0440\u0430\u0437\u043b\u0438\u0447\u0438\u044f \u0437\u0430 \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0435 <strong>O(n)<\/strong> \u0432\u0440\u0435\u043c\u044f. \u0418\u043c\u0435\u043d\u043d\u043e \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0438 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043b\u0430\u0441\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430 <code>Hashable<\/code>.<\/p>\n<p>  <\/p>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e, \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u0442\u0430\u043a\u0438\u0435 \u043d\u0430\u0431\u043e\u0440\u044b \u0432\u0430\u043b\u0438\u0434\u043d\u044b\u0445 \u0440\u0430\u0437\u043b\u0438\u0447\u0438\u0439 \u0441 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445, \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 <code>performBatchUpdates(_:completion:)<\/code> \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u0442 \u043a \u043f\u0430\u0434\u0435\u043d\u0438\u044e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u0414\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u043c\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0432 \u0434\u0432\u0430 \u044d\u0442\u0430\u043f\u0430. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u043c \u0440\u0430\u0437\u043b\u0438\u0447\u0438\u044f \u0432 \u0442\u0440\u0438 \u0448\u0430\u0433\u0430.<\/p>\n<p>  <\/p>\n<h4 id=\"vychislenie-razlichiy\">\u0412\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u0440\u0430\u0437\u043b\u0438\u0447\u0438\u0439<\/h4>\n<p>  <\/p>\n<ol>\n<li>\u0421\u0447\u0438\u0442\u0430\u0435\u043c \u0440\u0430\u0437\u043b\u0438\u0447\u0438\u044f \u043c\u0435\u0436\u0434\u0443 \u0441\u0442\u0430\u0440\u044b\u043c\u0438 \u0438 \u043d\u043e\u0432\u044b\u043c\u0438 (\u0444\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u043c\u0438) \u0441\u0435\u043a\u0446\u0438\u044f\u043c\u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0438\u0438 \u0438\u0445 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u043e\u0432 (<strong>id<\/strong>). \u041c\u043e\u0434\u0435\u043b\u0438 \u0432 \u0441\u0435\u043a\u0446\u0438\u044f\u0445 \u043d\u0430 \u0434\u0430\u043d\u043d\u043e\u043c \u0448\u0430\u0433\u0435 \u043d\u0435 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u044e\u0442\u0441\u044f.<\/li>\n<\/ol>\n<p>  <\/p>\n<pre><code class=\"swift\">let sectionsDiff = try calculateDiff(form: oldSections, to: newSections)<\/code><\/pre>\n<p>  <\/p>\n<ol>\n<li>\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u0443\u0442\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0440\u0430\u0437\u043b\u0438\u0447\u0438\u0439, \u0440\u0430\u0441\u0447\u0438\u0442\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u043c \u0448\u0430\u0433\u0435, \u043a \u0441\u0442\u0430\u0440\u044b\u043c \u0441\u0435\u043a\u0446\u0438\u044f\u043c. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043d\u0430 \u0434\u0430\u043d\u043d\u043e\u043c \u0448\u0430\u0433\u0435 \u043c\u044b \u0438\u043c\u0435\u0435\u043c \u0441\u0435\u043a\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0442 \u043d\u043e\u0432\u044b\u043c \u0441\u0435\u043a\u0446\u0438\u044f\u043c \u043f\u043e id. \u041e\u0434\u043d\u0430\u043a\u043e, \u0432 \u0441\u0435\u043a\u0446\u0438\u044f\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0441\u0442\u0430\u043b\u0438\u0441\u044c \u043d\u0430 \u0441\u0432\u043e\u0435\u043c \u043c\u0435\u0441\u0442\u0435 \u0438\u043b\u0438 \u0431\u044b\u043b\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u044b, \u0431\u0443\u0434\u0443\u0442 \u0441\u0442\u0430\u0440\u044b\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b. \u0410 \u0432 \u0442\u0435\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u044b\u043b\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u044b, \u0431\u0443\u0434\u0443\u0442 \u043d\u043e\u0432\u044b\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b.<\/li>\n<\/ol>\n<p>  <\/p>\n<pre><code class=\"swift\">let intermediateSections = applyDiff(sectionsDiff, to: oldSections)<\/code><\/pre>\n<p>  <\/p>\n<ol>\n<li>\u0414\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u043f\u0430\u0440\u044b \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u0441\u0435\u043a\u0446\u0438\u0439 (\u0441 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u043c id) \u0438\u0437 \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u043e\u0433\u043e \u0438 \u043d\u043e\u0432\u043e\u0433\u043e \u043d\u0430\u0431\u043e\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441\u0447\u0438\u0442\u0430\u0435\u043c \u0440\u0430\u0437\u043b\u0438\u0447\u0438\u044f \u0443\u0436\u0435 \u043c\u0435\u0436\u0434\u0443 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c\u0438. \u0414\u0430\u043b\u0435\u0435 \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u043c \u044d\u0442\u0438 \u043f\u043e\u043f\u0430\u0440\u043d\u044b\u0435 \u0440\u0430\u0437\u043b\u0438\u0447\u0438\u044f \u0432\u043c\u0435\u0441\u0442\u0435. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043d\u0430 \u044d\u0442\u043e\u043c \u0448\u0430\u0433\u0435 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0440\u0430\u0437\u043b\u0438\u0447\u0438\u044f \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0432 \u0443\u0441\u043b\u043e\u0432\u0438\u044f\u0445, \u0447\u0442\u043e \u0441\u0435\u043a\u0446\u0438\u0438 \u0441\u0442\u043e\u044f\u0442 \u0443\u0436\u0435 \u043d\u0430 \u0444\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u043e\u0437\u0438\u0446\u0438\u044f\u0445.<\/li>\n<\/ol>\n<p>  <\/p>\n<pre><code class=\"swift\">let rowsDiff = try calculateRowsDiff(from: intermediateSections, to: newSections)<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412 \u0438\u0442\u043e\u0433\u0435 \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0432\u0441\u044f \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u0430\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u0434\u043b\u044f \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u044b:<\/p>\n<p>  <\/p>\n<pre><code class=\"swift\">let diff = Diff(     sections: sectionsDiff,     rows: rowsDiff,     intermediateData: intermediateSections,     resultData: newSections )<\/code><\/pre>\n<p>  <\/p>\n<h4 id=\"obnovlenie-sostoyaniya-tablicy\">\u041e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u044b<\/h4>\n<p>  <\/p>\n<ol>\n<li><strong>\u041e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0441\u0435\u043a\u0446\u0438\u0439:<\/strong> \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0434\u043e \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u043e\u0433\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 (\u0438\u0437 \u0448\u0430\u0433\u0430 \u0434\u0432\u0430) \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0440\u0430\u0437\u043d\u043e\u0441\u0442\u044c, \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u043d\u043d\u0443\u044e \u043d\u0430 \u043f\u0435\u0440\u0432\u043e\u043c \u0448\u0430\u0433\u0435.<\/li>\n<\/ol>\n<p>  <\/p>\n<pre><code class=\"swift\">data = diff.intermediateData  tableView.insertSections(diff.sections.inserts, with: animationType) tableView.deleteSections(diff.sections.deletes, with: animationType) diff.sections.moves.forEach { tableView.moveSection($0.from, toSection: $0.to) }<\/code><\/pre>\n<p>  <\/p>\n<ol>\n<li><strong>\u041e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u044f\u0447\u0435\u0435\u043a:<\/strong> \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0434\u043e \u043d\u043e\u0432\u043e\u0433\u043e(\u0444\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0433\u043e) \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0440\u0430\u0437\u043d\u043e\u0441\u0442\u044c, \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u043d\u043d\u0443\u044e \u043d\u0430 \u0442\u0440\u0435\u0442\u044c\u0435\u043c \u0448\u0430\u0433\u0435.<\/li>\n<\/ol>\n<p>  <\/p>\n<pre><code class=\"swift\">data = diff.resultData  tableView.deleteRows(at: diff.rows.deletes, with: animationType) tableView.insertRows(at: diff.rows.inserts, with: animationType) diff.rows.moves.forEach { tableView.moveRow(at: $0.from, to: $0.to) }<\/code><\/pre>\n<p>  <\/p>\n<p><strong>\u0417\u0430\u043c\u0435\u0447\u0430\u043d\u0438\u0435 1:<\/strong> \u043a \u043c\u0438\u043d\u0443\u0441\u0430\u043c \u0442\u0430\u043a\u043e\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430 \u043c\u043e\u0436\u043d\u043e \u043e\u0442\u043d\u0435\u0441\u0442\u0438 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u044f \u044f\u0447\u0435\u0439\u043a\u0438 \u0438\u0437 \u043e\u0434\u043d\u043e\u0439 \u0441\u0435\u043a\u0446\u0438\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0432 \u0434\u0440\u0443\u0433\u0443\u044e. \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044f\u0447\u0435\u0439\u043a\u0430 \u00ab\u0443\u0434\u0430\u043b\u0438\u0442\u0441\u044f\u00bb \u0432 \u043e\u0434\u043d\u043e\u0439 \u0441\u0435\u043a\u0446\u0438\u0438 \u0438 \u00ab\u0432\u0441\u0442\u0430\u0432\u0438\u0442\u0441\u044f\u00bb \u0432 \u0434\u0440\u0443\u0433\u043e\u0439.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/w3\/lm\/l-\/w3lml-r_7hy_dts5orp7xa5czlq.gif\" width=\"250\"\/>  <\/p>\n<p><strong>\u0417\u0430\u043c\u0435\u0447\u0430\u043d\u0438\u0435 2:<\/strong> \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u043c\u0438, \u0442.\u0435. \u0438\u043c\u0435\u0442\u044c \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0439 \u0445\u0435\u0448. \u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u0435\u0442 \u0440\u0430\u0437\u043b\u0438\u0447\u0438\u044f \u0434\u0430\u0436\u0435 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u044f \u0434\u0443\u0431\u043b\u0438\u043a\u0430\u0442\u043e\u0432 \u0432 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438, \u043d\u043e \u0432 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u0434\u0443\u0431\u043b\u0438\u043a\u0430\u0442\u044b \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043b\u043e\u0436\u043d\u043e \u043f\u043e\u043c\u0435\u0447\u0435\u043d\u044b \u0434\u043b\u044f \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f, \u0430 \u0437\u0430\u0442\u0435\u043c, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u043f\u043e\u043c\u0435\u0447\u0435\u043d\u044b \u0434\u043b\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f. \u0422.\u043e. \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0434\u0435\u0442 \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u044f \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f, \u0430 \u0437\u0430\u0442\u0435\u043c \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043e\u0434\u043d\u043e\u0439 \u0438 \u0442\u043e\u0439 \u0436\u0435 \u044f\u0447\u0435\u0439\u043a\u0438. \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0431\u0435\u0437 \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0438 <code>adapter.update(with: sections, animated: false)<\/code> \u0440\u0430\u0437\u043d\u043e\u0441\u0442\u0438 \u0432\u043e\u043e\u0431\u0449\u0435 \u043d\u0435 \u0431\u0443\u0434\u0443\u0442 \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0442\u044c\u0441\u044f \u0438 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0432\u043e\u0432\u0441\u0435.<\/p>\n<p>  <\/p>\n<h3 id=\"nastroyka-cherez-configurable-protokol\">\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0447\u0435\u0440\u0435\u0437 <code>Configurable<\/code> \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b<\/h3>\n<p>  <\/p>\n<p>\u041f\u0440\u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0435 \u044f\u0447\u0435\u0435\u043a \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e\u0433\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u0438\u043b\u044c\u043d\u043e \u0440\u0430\u0437\u0440\u0430\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u043d\u0430\u043b\u0438\u0447\u0438\u0438 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u0440\u0430\u0437\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432 \u044f\u0447\u0435\u0435\u043a:<\/p>\n<p>  <\/p>\n<pre><code class=\"swift\">let user = users[indexPath.row]  let cell = tableView.dequeueReusableCell(     withIdentifier: cellId,     for: indexPath ) as! Cell  cell.setup(with: user)<\/code><\/pre>\n<p>  <\/p>\n<p>\u0422\u0430\u043a\u0436\u0435 \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0441\u0432\u043e\u0431\u043e\u0434\u0443 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0443 \u0432 \u0432\u044b\u0431\u043e\u0440\u0435 \u0431\u0430\u0437\u043e\u0432\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u044f\u0447\u0435\u0439\u043a\u0438 \u0438 \u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0439 \u0442\u0438\u043f \u043c\u043e\u0434\u0435\u043b\u0438 \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0434\u043b\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0431\u044b\u043b\u043e \u043f\u0440\u0438\u043d\u044f\u0442\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u044b \u0441\u043e \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u043c\u0438 \u0442\u0438\u043f\u0430\u043c\u0438 (<em>associatedtype<\/em>).<\/p>\n<p>  <\/p>\n<p>\u0422\u0430\u043a \u043f\u043e\u044f\u0432\u0438\u043b\u0441\u044f \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b <code>Configurable<\/code>, \u0438\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u043e\u043c \u044f\u0447\u0435\u0439\u043a\u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u0432\u0441\u0435 \u0432\u044b\u0448\u0435\u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u043e\u0435:<\/p>\n<p>  <\/p>\n<pre><code class=\"swift\">protocol Configurable {      associatedtype ItemType: Any     func setup(with item: ItemType) }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e, \u043f\u043e\u0441\u043b\u0435 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u044f\u0447\u0435\u0439\u043a\u0438 \u043c\u0435\u0442\u043e\u0434\u043e\u043c <code>dequeueReusableCell(withIdentifier:for:)<\/code> \u043c\u044b \u043d\u0435 \u0441\u043c\u043e\u0436\u0435\u043c \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u0435\u0435 \u043a \u0442\u0438\u043f\u0443 <code>Configurable<\/code> \u0438\u0437-\u0437\u0430 \u043d\u0430\u043b\u0438\u0447\u0438\u044f \u0432 \u043d\u0435\u043c \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430 <code>ItemType<\/code>. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u043b\u0438 \u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b <code>AnyConfigurable<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"swift\">protocol AnyConfigurable {      func anySetup(with item: Any) }<\/code><\/pre>\n<p>  <\/p>\n<p>\u043a \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u0438 \u0431\u0443\u0434\u0435\u043c \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043e\u0431\u044a\u0435\u043a\u0442 \u044f\u0447\u0435\u0439\u043a\u0438, \u0441 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0435\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 \u0434\u043b\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438:<\/p>\n<p>  <\/p>\n<pre><code class=\"swift\">let cell = tableView.dequeueReusableCell(withIdentifier: cellId, for: indexPath)  if let cell = cell as? AnyConfigurable {     cell.anySetup(with: item) }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0410 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b <code>Configurable<\/code> \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u043c \u043e\u0442 <code>AnyConfigurable<\/code> \u0438 \u0438\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0438\u0440\u0443\u0435\u0442 \u0435\u0433\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<p>  <\/p>\n<pre><code class=\"swift\">extension Configurable {      func anySetup(with item: Any) {         if let item = item as? ItemType {             setup(with: item)         }     } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043c\u044b \u043a\u0430\u043a-\u0431\u044b \u00ab\u0441\u043a\u0440\u044b\u043b\u0438\u00bb \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b \u0441\u043e \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u043c\u0438 \u0442\u0438\u043f\u043e\u043c \u043e\u0431\u044b\u0447\u043d\u044b\u043c \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u043e\u043c \u0432\u043d\u0443\u0442\u0440\u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438, \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u043e\u0441\u0442\u0430\u0432\u0438\u0432 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0443 \u0443\u0434\u043e\u0431\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441. \u0412\u0441\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u0442\u0438\u043f\u043e\u0432 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u043e \u044d\u0442\u043e\u043c\u0443 \u043f\u043e\u0432\u043e\u0434\u0443 \u043f\u0430\u0434\u0435\u043d\u0438\u0439 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442.<\/p>\n<p>  <\/p>\n<p>\u0421\u0442\u043e\u0438\u0442 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u0442\u0430\u043a\u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 Swift \u043f\u0440\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 type-erased wrappers. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 AnyHashable, AnyIndex.<\/p>\n<p>  <\/p>\n<p><strong>\u0417\u0430\u043c\u0435\u0447\u0430\u043d\u0438\u0435:<\/strong> \u0440\u0435\u0430\u043b\u044c\u043d\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0432 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f \u043e\u0442 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u043e\u0439 \u0432\u044b\u0448\u0435. \u0410 \u0438\u043c\u0435\u043d\u043d\u043e: \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u044b \u0432\u044b\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0439 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0435\u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u044f \u043e\u0436\u0438\u0434\u0430\u0435\u043c\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u043c\u043e\u0434\u0435\u043b\u0438 \u0438 \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u043e\u0433\u043e.<\/p>\n<p>  <\/p>\n<h2 id=\"ssylka-na-github\">\u0421\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 GitHub<\/h2>\n<p>  <\/p>\n<p>\u0412 \u0438\u0442\u043e\u0433\u0435 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0440\u0435\u0448\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0443\u0434\u043e\u0431\u043d\u043e \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c \u044f\u0447\u0435\u0439\u043a\u0438, \u043f\u0438\u0441\u0430\u0442\u044c \u043c\u0435\u043d\u044c\u0448\u0435 \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u0438 \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0438 \u0432 \u043f\u0440\u0438\u0434\u0430\u0447\u0443. \u0412 \u0442\u043e \u0436\u0435 \u0432\u0440\u0435\u043c\u044f \u043e\u0441\u0442\u0430\u043b\u0430\u0441\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043d\u0438\u0437\u043a\u043e\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u043e\u0439 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0438 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u0430 \u043f\u0440\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438.<\/p>\n<p>  <\/p>\n<p><a href=\"https:\/\/github.com\/MobileUpLLC\/TableAdapter\">\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043d\u0430 GitHub<\/a><\/p>\n<\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/504464\/\"> https:\/\/habr.com\/ru\/post\/504464\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/504464\/\">\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/q8\/-l\/xp\/q8-lxpaxgl4muu9wok1htffafbg.png\"\/><\/p>\n<p>  <\/p>\n<p>\u041f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 <code>UITableView<\/code> \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0435\u0449\u0435 \u0431\u043e\u043b\u044c\u0448\u0435 \u0443\u0441\u043b\u043e\u0436\u043d\u044f\u0435\u0442\u0441\u044f, \u0435\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u043e \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0442\u044c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0430\u043d\u0438\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u043e. Apple \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043b\u0430 \u0441\u0432\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u044d\u0442\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u043d\u0430 WWDC 2019, \u043d\u043e \u043e\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0441 iOS 13. \u0410 \u0443 \u043d\u0430\u0441, \u043a\u0430\u043a \u0443 \u0441\u0442\u0443\u0434\u0438\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043c\u043e\u0431\u0438\u043b\u044c\u043d\u044b\u0439 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439, \u043d\u0435\u0442 \u0442\u0430\u043a\u043e\u0439 \u0440\u043e\u0441\u043a\u043e\u0448\u0438 \u0432 \u0432\u044b\u0431\u043e\u0440\u0435 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 iOS.<\/p>\n<p>  <\/p>\n<p>\u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043b\u0438 \u043d\u0430\u0448\u0435 \u0432\u0438\u0434\u0435\u043d\u0438\u0435 data-driven \u043f\u043e\u0434\u0445\u043e\u0434\u0430 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u043c\u0438, \u043f\u043e\u043f\u0443\u0442\u043d\u043e \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0432 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0443 \u044f\u0447\u0435\u0435\u043a. \u0418 \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 \u0430\u043d\u0438\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u043e \u043d\u0430 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u043c \u043f\u043e\u0434\u0441\u0447\u0435\u0442\u0435 \u0440\u0430\u0437\u043b\u0438\u0447\u0438\u0439 \u043c\u0435\u0436\u0434\u0443 \u0441\u0442\u0430\u0440\u044b\u043c\u0438 \u0438 \u043d\u043e\u0432\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0437\u0430 \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f <strong>O(n)<\/strong>. \u0412\u0441\u0435 \u044d\u0442\u043e \u043c\u044b \u043e\u0444\u043e\u0440\u043c\u0438\u043b\u0438 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0443\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043d\u0430\u0437\u0432\u0430\u043b\u0438 TableAdapter.<\/p>\n<p>  <\/p>\n<p>\u041e \u0442\u043e\u043c, \u0447\u0442\u043e \u0443 \u043d\u0430\u0441 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u0438 \u043a\u0430\u043a \u043c\u044b \u043a \u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0438\u0448\u043b\u0438, \u0438 \u043f\u043e\u0439\u0434\u0435\u0442 \u0440\u0435\u0447\u044c \u0432 \u0441\u0442\u0430\u0442\u044c\u0435.<\/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-304501","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/304501","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=304501"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/304501\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=304501"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=304501"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=304501"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}