{"id":202960,"date":"2013-12-15T11:02:03","date_gmt":"2013-12-15T07:02:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=202960"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=202960","title":{"rendered":"<span class=\"post_title\">\u041f\u0430\u0442\u0442\u0435\u0440\u043d\u044b \u041e\u041e\u041f \u0432 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u0445 \u0434\u043b\u044f iOS<\/span>"},"content":{"rendered":"<div class=\"content html_format\">\n<h3>\u041e\u0442 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0447\u0438\u043a\u0430<\/h3>\n<p>  \u0418\u0441\u043a\u0430\u043b\u0438 \u0442\u0443\u0442 \u0434\u0432\u0443\u0445 \u0440\u0443\u0441\u0441\u043a\u043e\u044f\u0437\u044b\u0447\u043d\u044b\u0445 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 \u2014 \u043d\u0430 iOS \u0438 \u043d\u0430 C++ \u043f\u043e\u0434 Windows. \u0412\u0438\u0434\u0435\u043b \u0434\u0435\u0441\u044f\u0442\u043a\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u043d\u044b\u0445 \u0442\u0435\u0441\u0442\u043e\u0432. \u0420\u0430\u0437\u043d\u0438\u0446\u0430 \u0432 \u0437\u043d\u0430\u043d\u0438\u0438 \u041e\u041e\u041f \u043c\u0435\u0436\u0434\u0443 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u0435\u043b\u044f\u043c\u0438 \u0434\u0432\u0443\u0445 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c \u2014 \u043e\u0433\u0440\u043e\u043c\u043d\u0430\u044f. \u041d\u0430 C++ \u043e\u0431\u044b\u0447\u043d\u043e \u043a\u0440\u0430\u0441\u0438\u0432\u044b\u0439 \u0440\u0430\u0441\u0448\u0438\u0440\u044f\u0435\u043c\u044b\u0439 \u043a\u043e\u0434, \u043a\u0430\u043a \u0441\u0430\u043c\u043e \u0441\u043e\u0431\u043e\u0439 \u0440\u0430\u0437\u0443\u043c\u0435\u044e\u0449\u0435\u0435\u0441\u044f. \u041d\u0430 Objective C \u043a\u0430\u0440\u0442\u0438\u043d\u0430 \u0443\u0434\u0440\u0443\u0447\u0430\u044e\u0449\u0430\u044f. \u041f\u043e\u0447\u0442\u0438 \u0432\u0441\u0435 iOS-\u043a\u0430\u043d\u0434\u0438\u0434\u0430\u0442\u044b \u043d\u0435 \u0437\u043d\u0430\u043b\u0438 \u041e\u041e\u041f \u0434\u0430\u043b\u044c\u0448\u0435 <s>\u0441\u0432\u043e\u0435\u0433\u043e&nbsp;\u043d\u043e\u0441\u0430<\/s> <code>NSString<\/code>&#8216;\u043e\u0432 \u0438 <code>AppDelegate<\/code>&#8216;\u043e\u0432.<\/p>\n<p>  \u041f\u043e\u043d\u044f\u0442\u043d\u043e, \u0447\u0442\u043e \u043f\u043b\u044e\u0441\u044b \u0443\u0447\u0430\u0442 \u043f\u043e \u0421\u0442\u0440\u0430\u0443\u0441\u0442\u0440\u0443\u043f\u0443 \u0438 \u00ab\u0431\u0430\u043d\u0434\u0435 \u0447\u0435\u0442\u044b\u0440\u0451\u0445\u00bb, \u0430 Objective C \u2014 \u0431\u043e\u043b\u044c\u0448\u0435 \u043f\u043e \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b\u0430\u043c \u0438 Stack&nbsp;Overflow. \u0424\u0430\u0441\u0442\u0444\u0443\u0434-\u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435 \u043d\u0435 \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043c\u0435\u0441\u0442\u0430 \u043d\u0430 \u0444\u0443\u043d\u0434\u0430\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0432\u043e\u043f\u0440\u043e\u0441\u044b\u2026 \u041d\u043e \u0442\u0430\u043a\u043e\u0439 \u0440\u0430\u0437\u043d\u0438\u0446\u044b \u044f \u043d\u0435 \u043e\u0436\u0438\u0434\u0430\u043b.<\/p>\n<p>  \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u043f\u0435\u0440\u0435\u0432\u0451\u043b \u043f\u043e\u0441\u0442, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0434\u0430\u043d\u044b \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u0435 \u0441\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u043e \u0448\u0430\u0431\u043b\u043e\u043d\u0430\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0441 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u043c\u0438 \u043d\u0430 iOS\u2026 \u00ab\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u0435\u00bb? \u0410\u0433\u0430, \u0437\u043d\u0430\u0447\u0438\u0442, \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0435\u043d\u0438\u0435? \u041d\u0435\u0442, \u043d\u0435 \u0431\u0443\u0434\u0435\u0442. \u0414\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0438\u0435 \u0441\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u0432\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0435 \u0438\u0437 \u043e\u043f\u044b\u0442\u0430, \u0438\u0437 <b>\u043f\u043e\u043f\u044b\u0442\u043e\u043a<\/b> \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043a\u043e\u0434\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u043e\u0432. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c\u0441\u044f, \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e, \u0444\u0430\u0441\u0430\u0434 \u0437\u0434\u0430\u043d\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u0442\u043e\u0440\u0447\u0430\u0442\u044c \u0438\u0437 \u0434\u044b\u043c\u043e\u0432\u043e\u0439 \u0442\u0440\u0443\u0431\u044b, \u043d\u043e \u043f\u043e\u0442\u043e\u043c \u043f\u0440\u0438\u0434\u0451\u0442 \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0433\u0434\u0435 \u043a\u0430\u043a\u0438\u0435 \u043f\u0440\u0438\u0451\u043c\u044b \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u043f\u043e\u043c\u043e\u0433\u0430\u044e\u0442.<\/p>\n<p>  \u041a\u0430\u0447\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u0430\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u041f\u041e \u2014 \u0442\u0432\u043e\u0440\u0447\u0435\u0441\u043a\u0438\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441, \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0439 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0439 \u0433\u043e\u043b\u043e\u0432\u044b. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043e\u0431\u0449\u0435\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438: <code>if&nbsp;(A&nbsp;and&nbsp;(B&nbsp;or&nbsp;C)) then&nbsp;use&nbsp;Pattern_N;<\/code><a name=\"habracut\"><\/a><\/p>\n<p>  <b>\u041f\u0440\u043e\u0441\u0442\u043e \u043f\u043e\u0447\u0430\u0449\u0435 \u0441\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0439\u0442\u0435 \u0441\u0435\u0431\u044f: \u0442\u043e, \u0447\u0442\u043e \u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u2014 \u043a\u0440\u0430\u0441\u0438\u0432\u043e?<\/b><\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">Disclaimer<\/b><\/p>\n<div class=\"spoiler_text\">\u041f\u0430\u0442\u0442\u0435\u0440\u043d\u044b \u2014 \u043d\u0435 \u043f\u0430\u043d\u0430\u0446\u0435\u044f, \u043d\u0435 \u043b\u0435\u043a\u0430\u0440\u0441\u0442\u0432\u043e \u043e\u0442 \u043a\u0440\u0438\u0432\u044b\u0445 \u0440\u0443\u043a \u0438 \u043d\u0435 \u0437\u0430\u043c\u0435\u043d\u0430 \u0434\u043b\u044f \u043c\u043e\u0437\u0433\u043e\u0432. \u0412\u043e\u0442 \u044d\u0442\u043e\u0442 \u0442\u0440\u0430\u0444\u0430\u0440\u0435\u0442:<\/p>\n<p>  <a href=\"https:\/\/developer.apple.com\/library\/mac\/referencelibrary\/GettingStarted\/RoadMapOSX\/chapters\/08_DesignPatterns.html\"><img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/e4b\/c14\/5b3\/e4bc145b3b8ad30cd9a6b6b94041a544.png\"\/><\/a><\/p>\n<p>  \u041e\u043d \u0441\u0430\u043c \u043d\u0435 \u0440\u0438\u0441\u0443\u0435\u0442! \u0420\u0438\u0441\u0443\u0435\u0448\u044c \u2014 \u0442\u044b.<\/p><\/div>\n<\/div>\n<p>  <\/p>\n<h2>\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u043f\u0430\u0442\u0442\u0435\u0440\u043d<\/h2>\n<p>  \u0418\u0434\u0435\u044f \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u043e\u0432 \u0432\u043e\u0437\u043d\u0438\u043a\u043b\u0430 40 \u043b\u0435\u0442 \u043d\u0430\u0437\u0430\u0434 \u0443 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u043e\u0440\u0430 <a href=\"http:\/\/books.google.ru\/books\/about\/A_Pattern_Language.html?id=hwAHmktpk5IC&amp;redir_esc=y\">\u041a\u0440\u0438\u0441\u0442\u043e\u0444\u0435\u0440\u0430 \u0410\u043b\u0435\u043a\u0441\u0430\u043d\u0434\u0435\u0440\u0430<\/a>:  <\/p>\n<blockquote><p>\u041b\u044e\u0431\u043e\u0439 \u043f\u0430\u0442\u0442\u0435\u0440\u043d \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u0437\u0430\u0434\u0430\u0447\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u043d\u043e\u0432\u0430 \u0438 \u0441\u043d\u043e\u0432\u0430 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u0432 \u043d\u0430\u0448\u0435\u0439 \u0440\u0430\u0431\u043e\u0442\u0435, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u0440\u0438\u043d\u0446\u0438\u043f \u0435\u0451 \u0440\u0435\u0448\u0435\u043d\u0438\u044f, \u043f\u0440\u0438\u0447\u0451\u043c \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0447\u0442\u043e \u044d\u0442\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0442\u043e\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0438\u043b\u043b\u0438\u043e\u043d \u0440\u0430\u0437, \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0438\u0437\u043e\u0431\u0440\u0435\u0442\u0430\u044f \u0437\u0430\u043d\u043e\u0432\u043e.<\/p><\/blockquote>\n<p>  \u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u044b \u044d\u0442\u043e \u0443\u0432\u0438\u0434\u0435\u043b\u0438 \u0438 <a href=\"http:\/\/www.piter.com\/book.phtml?978549600389&amp;barcode=978549600389\">\u0441\u043a\u0430\u0437\u0430\u043b\u0438<\/a>:  <\/p>\n<blockquote><p>\u0425\u043e\u0442\u044f \u0410\u043b\u0435\u043a\u0441\u0430\u043d\u0434\u0440 \u0438\u043c\u0435\u043b \u0432 \u0432\u0438\u0434\u0443 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u044b, \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u044e\u0449\u0438\u0435 \u043f\u0440\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u0437\u0434\u0430\u043d\u0438\u0439 \u0438 \u0433\u043e\u0440\u043e\u0434\u043e\u0432, \u043d\u043e \u0435\u0433\u043e \u0441\u043b\u043e\u0432\u0430 \u0432\u0435\u0440\u043d\u044b \u0438 \u0432 \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0438 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u043e\u0432 \u043e\u0431\u044a\u0435\u043a\u0442\u043d\u043e-\u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u041d\u0430\u0448\u0438 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0432\u044b\u0440\u0430\u0436\u0430\u044e\u0442\u0441\u044f \u0432 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0438 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u0432, \u0430 \u043d\u0435 \u0441\u0442\u0435\u043d \u0438 \u0434\u0432\u0435\u0440\u0435\u0439, \u043d\u043e \u0432 \u043e\u0431\u043e\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u0441\u043c\u044b\u0441\u043b \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0430 \u2013 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0438\u0442\u044c \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u0432 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u043c \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435.<\/p><\/blockquote>\n<p>  <img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/cd5\/dae\/71b\/cd5dae71bb554825a5c72e98c4e09b1e.png\"\/><\/p>\n<p>  \u0412 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 <a href=\"http:\/\/ru.wikipedia.org\/wiki\/%D0%A8%D0%B0%D0%B1%D0%BB%D0%BE%D0%BD_%D0%BF%D1%80%D0%BE%D0%B5%D0%BA%D1%82%D0%B8%D1%80%D0%BE%D0%B2%D0%B0%D0%BD%D0%B8%D1%8F\">\u0432\u0438\u043a\u0438\u043f\u0435\u0434\u0438\u0438<\/a>, \u044f \u043d\u0435 \u0431\u0443\u0434\u0443 \u043d\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043f\u0430\u0442\u0442\u0435\u0440\u043d \u00ab\u0448\u0430\u0431\u043b\u043e\u043d\u043e\u043c\u00bb, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u043f\u0443\u0442\u0430\u0442\u044c \u0441 <a href=\"http:\/\/ru.wikipedia.org\/wiki\/%D0%A8%D0%B0%D0%B1%D0%BB%D0%BE%D0%BD%D1%8B_C%2B%2B\">\u0448\u0430\u0431\u043b\u043e\u043d\u0430\u043c\u0438 C++<\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0442\u0430\u043a\u0436\u0435 \u0438\u043c\u0435\u044e\u0442 \u043f\u0440\u0430\u0432\u043e \u043d\u0430 \u0436\u0438\u0437\u043d\u044c \u0432 Objective C.<\/p>\n<p>  \u041d\u0430 \u044d\u0442\u043e\u043c \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u044e \u0432\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u0435 \u0438 \u043d\u0430\u043a\u043e\u043d\u0435\u0446 \u043f\u0435\u0440\u0435\u0434\u0430\u044e \u0441\u043b\u043e\u0432\u043e \u0430\u0432\u0442\u043e\u0440\u0443 \u0441\u0442\u0430\u0442\u044c\u0438. <i> \u2014 \u041f\u0440\u0438\u043c. \u043f\u0435\u0440. \ud83d\ude42<\/i><\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0425\u043e\u0442\u044f \u043d\u0435\u0442, \u0435\u0449\u0451 \u043e\u0434\u043d\u043e \u043b\u0438\u0440\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043e\u0442\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u0435 \u043e \u0432\u0430\u0436\u043d\u043e\u0441\u0442\u0438 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u043e\u0432.<\/b><\/p>\n<div class=\"spoiler_text\">\u2026\u041f\u0443\u0442\u0435\u0448\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u0438\u043a\u0438 \u043f\u0440\u043e\u0448\u043b\u0438 \u043f\u043e \u043f\u0435\u0440\u0435\u0443\u043b\u043a\u0443 \u0438 \u043e\u0447\u0443\u0442\u0438\u043b\u0438\u0441\u044c \u0432 \u043a\u0432\u0430\u0440\u0442\u0430\u043b\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u044b\u043b \u0437\u0430\u0441\u0442\u0440\u043e\u0435\u043d \u0434\u043e\u043c\u0430\u043c\u0438 \u0441 \u043a\u043e\u043b\u043e\u043d\u043d\u0430\u043c\u0438. \u0417\u0434\u0435\u0441\u044c \u0431\u044b\u043b\u0438 \u043a\u043e\u043b\u043e\u043d\u043d\u044b \u0438 \u043f\u0440\u044f\u043c\u044b\u0435, \u0438 \u043a\u0440\u0438\u0432\u044b\u0435, \u0438 \u043a\u0440\u0443\u0447\u0435\u043d\u044b\u0435, \u0438 \u0432\u0438\u0442\u044b\u0435, \u0438 \u0441\u043f\u0438\u0440\u0430\u043b\u044c\u043d\u044b\u0435, \u0438 \u043d\u0430\u043a\u043b\u043e\u043d\u043d\u044b\u0435, \u0438 \u043f\u0440\u0438\u043f\u043b\u044e\u0441\u043d\u0443\u0442\u044b\u0435, \u0438 \u043a\u043e\u0441\u043e\u043f\u0443\u0437\u044b\u0435, \u0438 \u0431\u043b\u0438\u043d\u043e\u043e\u0431\u0440\u0430\u0437\u043d\u044b\u0435, \u0438 \u0434\u0430\u0436\u0435 \u0442\u0430\u043a\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043d\u0435 \u043f\u043e\u0434\u0431\u0435\u0440\u0435\u0448\u044c \u0438\u043c\u0435\u043d\u0438. \u041a\u0430\u0440\u043d\u0438\u0437\u044b \u0443 \u0434\u043e\u043c\u043e\u0432 \u0442\u043e\u0436\u0435 \u0431\u044b\u043b\u0438 \u0438 \u043f\u0440\u044f\u043c\u044b\u0435, \u0438 \u043a\u043e\u0441\u044b\u0435, \u0438 \u043a\u0440\u0438\u0432\u044b\u0435, \u0438 \u043b\u043e\u043c\u0430\u043d\u044b\u0435, \u0438 \u0437\u0438\u0433\u0437\u0430\u0433\u043e\u043e\u0431\u0440\u0430\u0437\u043d\u044b\u0435. \u0423 \u043e\u0434\u043d\u0438\u0445 \u0434\u043e\u043c\u043e\u0432 \u043a\u043e\u043b\u043e\u043d\u043d\u044b \u043d\u0430\u0445\u043e\u0434\u0438\u043b\u0438\u0441\u044c \u043d\u0435 \u0432\u043d\u0438\u0437\u0443, \u043a\u0430\u043a \u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f, \u0430 \u0441\u0432\u0435\u0440\u0445\u0443, \u043d\u0430 \u043a\u0440\u044b\u0448\u0430\u0445; \u0443 \u0434\u0440\u0443\u0433\u0438\u0445 \u0434\u043e\u043c\u043e\u0432 \u043a\u043e\u043b\u043e\u043d\u043d\u044b \u0431\u044b\u043b\u0438 \u0432\u043d\u0438\u0437\u0443, \u0437\u0430\u0442\u043e \u0441\u0430\u043c\u0438 \u0434\u043e\u043c\u0430 \u0441\u0442\u043e\u044f\u043b\u0438 \u0432\u0432\u0435\u0440\u0445\u0443, \u043d\u0430\u0434 \u043a\u043e\u043b\u043e\u043d\u043d\u0430\u043c\u0438; \u0443 \u0442\u0440\u0435\u0442\u044c\u0438\u0445 \u043a\u043e\u043b\u043e\u043d\u043d\u044b \u0431\u044b\u043b\u0438 \u043f\u043e\u0434\u0432\u0435\u0448\u0435\u043d\u044b \u043a \u043a\u0430\u0440\u043d\u0438\u0437\u0430\u043c \u0438 \u0431\u043e\u043b\u0442\u0430\u043b\u0438\u0441\u044c \u043d\u0430\u0434 \u0433\u043e\u043b\u043e\u0432\u0430\u043c\u0438 \u043f\u0440\u043e\u0445\u043e\u0436\u0438\u0445. \u0411\u044b\u043b \u0434\u043e\u043c, \u0443 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043a\u0430\u0440\u043d\u0438\u0437 \u043d\u0430\u0445\u043e\u0434\u0438\u043b\u0441\u044f \u0432\u043d\u0438\u0437\u0443, \u0430 \u043a\u043e\u043b\u043e\u043d\u043d\u044b \u0441\u0442\u043e\u044f\u043b\u0438 \u0432\u0432\u0435\u0440\u0445 \u043d\u043e\u0433\u0430\u043c\u0438 \u0438 \u0432\u0434\u043e\u0431\u0430\u0432\u043e\u043a \u043f\u043e\u043a\u043e\u0441\u0438\u043b\u0438\u0441\u044c \u043d\u0430\u0431\u043e\u043a. \u0411\u044b\u043b \u0442\u0430\u043a\u0436\u0435 \u0434\u043e\u043c, \u0443 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043a\u043e\u043b\u043e\u043d\u043d\u044b \u0441\u0442\u043e\u044f\u043b\u0438 \u043f\u0440\u044f\u043c\u043e, \u043d\u043e \u0441\u0430\u043c \u0434\u043e\u043c \u0441\u0442\u043e\u044f\u043b \u043a\u043e\u0441\u043e, \u0441\u043b\u043e\u0432\u043d\u043e \u0441\u043e\u0431\u0438\u0440\u0430\u043b\u0441\u044f \u0440\u0443\u0445\u043d\u0443\u0442\u044c \u043d\u0430 \u0433\u043e\u043b\u043e\u0432\u044b \u043f\u0440\u043e\u0445\u043e\u0436\u0438\u0445. \u0415\u0449\u0435 \u0431\u044b\u043b \u0434\u043e\u043c, \u0443 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043a\u043e\u043b\u043e\u043d\u043d\u044b \u043d\u0430\u043a\u043b\u043e\u043d\u0438\u043b\u0438\u0441\u044c \u0432 \u043e\u0434\u043d\u0443 \u0441\u0442\u043e\u0440\u043e\u043d\u0443, \u0430 \u0441\u0430\u043c \u0434\u043e\u043c \u043d\u0430\u043a\u043b\u043e\u043d\u0438\u043b\u0441\u044f \u0432 \u0434\u0440\u0443\u0433\u0443\u044e, \u0442\u0430\u043a \u0447\u0442\u043e \u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c, \u0431\u0443\u0434\u0442\u043e \u0432\u0441\u0435 \u044d\u0442\u043e \u0441\u0435\u0439\u0447\u0430\u0441 \u0440\u0443\u0445\u043d\u0435\u0442 \u043d\u0430 \u0437\u0435\u043c\u043b\u044e \u0438 \u0440\u0430\u0441\u0441\u044b\u043f\u043b\u0435\u0442\u0441\u044f \u0432 \u043f\u0440\u0430\u0445.<\/p>\n<p>   \u2014 \u0412\u044b \u043d\u0430 \u044d\u0442\u0438 \u043a\u043e\u0441\u044b\u0435 \u0434\u043e\u043c\u0430 \u043d\u0435 \u0441\u043c\u043e\u0442\u0440\u0438\u0442\u0435, \u2014 \u0441\u043a\u0430\u0437\u0430\u043b \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u043e\u0440 \u041a\u0443\u0431\u0438\u043a. \u2014 \u041a\u043e\u0433\u0434\u0430-\u0442\u043e \u0443 \u043d\u0430\u0441 \u0431\u044b\u043b\u0430 \u043c\u043e\u0434\u0430 \u0443\u0432\u043b\u0435\u043a\u0430\u0442\u044c\u0441\u044f \u0441\u0442\u0440\u043e\u0438\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u043e\u043c \u0434\u043e\u043c\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0438 \u043d\u0430 \u0447\u0442\u043e \u043d\u0435 \u043f\u043e\u0445\u043e\u0436\u0438. \u0412\u043e\u0442 \u0438 \u043d\u0430\u0434\u0435\u043b\u0430\u043b\u0438 \u0442\u0430\u043a\u043e\u0433\u043e \u0431\u0435\u0437\u043e\u0431\u0440\u0430\u0437\u0438\u044f, \u0447\u0442\u043e \u0442\u0435\u043f\u0435\u0440\u044c \u0434\u0430\u0436\u0435 \u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0441\u043e\u0432\u0435\u0441\u0442\u043d\u043e!<\/p>\n<p>  <i>\u041d. \u041d\u043e\u0441\u043e\u0432. \u00ab\u041d\u0435\u0437\u043d\u0430\u0439\u043a\u0430 \u0432 \u0421\u043e\u043b\u043d\u0435\u0447\u043d\u043e\u043c \u0433\u043e\u0440\u043e\u0434\u0435\u00bb<\/i><\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/9a1\/043\/a49\/9a1043a49fee38bc3b9ff654480f3b66.png\"\/><\/div>\n<\/div>\n<p>  <\/p>\n<hr\/>\n<p>  \u0425\u043e\u0442\u044f \u043c\u043d\u043e\u0433\u0438\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u0441\u043e\u0433\u043b\u0430\u0441\u043d\u044b \u0441 \u0442\u0435\u043c, \u0447\u0442\u043e \u0442\u0435\u043c\u0430 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u043e\u0432 \u043e\u0447\u0435\u043d\u044c \u0432\u0430\u0436\u043d\u0430, \u2014 \u0435\u0439 \u043f\u043e\u0441\u0432\u044f\u0449\u0435\u043d\u043e \u043d\u0435 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043c\u043d\u043e\u0433\u043e \u0441\u0442\u0430\u0442\u0435\u0439, \u0438 \u043c\u044b \u0447\u0430\u0441\u0442\u043e \u043d\u0435 \u0443\u0434\u0435\u043b\u044f\u0435\u043c \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0430\u043c \u0434\u043e\u0441\u0442\u043e\u0439\u043d\u043e\u0433\u043e \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u043f\u0440\u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0438 \u043a\u043e\u0434\u0430.<\/p>\n<p>  \u041f\u0430\u0442\u0442\u0435\u0440\u043d \u2014 \u044d\u0442\u043e \u043e\u0431\u0440\u0430\u0437\u0435\u0446 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b. \u0420\u0435\u0448\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0432\u0442\u043e\u0440\u0438\u0442\u044c \u0432 \u0434\u0440\u0443\u0433\u043e\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435. \u041f\u0430\u0442\u0442\u0435\u0440\u043d\u044b \u0443\u043f\u0440\u043e\u0449\u0430\u044e\u0442 \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043a\u043e\u0434\u0430. \u041e\u043d\u0438 \u043f\u043e\u043c\u043e\u0433\u0430\u044e\u0442 \u043f\u0438\u0441\u0430\u0442\u044c \u0441\u043b\u0430\u0431\u043e-\u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0439 \u043a\u043e\u0434 (loosely coupled) \u2014 \u0442\u0430\u043a\u043e\u0439 \u043a\u043e\u0434, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043c\u043e\u0436\u043d\u043e \u043b\u0435\u0433\u043a\u043e \u043c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b, \u0438\u043b\u0438 \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u0446\u0435\u043b\u044b\u0439 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u043d\u0430 \u0435\u0433\u043e \u0430\u043d\u0430\u043b\u043e\u0433, <s>\u043f\u043e\u0447\u0442\u0438<\/s> \u043d\u0435 \u0442\u0440\u043e\u0433\u0430\u044f \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u043f\u0440\u043e\u0435\u043a\u0442\u0430.<\/p>\n<p>  \u0415\u0441\u043b\u0438 \u0432\u044b \u043d\u043e\u0432\u0438\u0447\u043e\u043a \u0432 \u0442\u0435\u043c\u0435 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u043e\u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u0442\u043e \u0443 \u043c\u0435\u043d\u044f \u0434\u043b\u044f \u0432\u0430\u0441 \u0445\u043e\u0440\u043e\u0448\u0438\u0435 \u043d\u043e\u0432\u043e\u0441\u0442\u0438! \u041f\u0435\u0440\u0432\u0430\u044f: \u0432\u044b \u0443\u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435 \u043e\u0433\u0440\u043e\u043c\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u043e\u0432, \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0442\u0435\u043c \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0430\u043c, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0443\u0441\u0442\u0440\u043e\u0435\u043d Cocoa. (\u0412\u043f\u0440\u043e\u0447\u0435\u043c, \u044d\u0442\u043e \u043d\u0435 \u043c\u0435\u0448\u0430\u0435\u0442 \u044d\u043f\u043f\u043b\u0443 \u0431\u044b\u0434\u043b\u043e\u043a\u043e\u0434\u0438\u0442\u044c \u0432 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u0445 \u043d\u0430 developer.apple.com \u2014 <i>\u041f\u0440\u0438\u043c. \u043f\u0435\u0440.<\/i>) \u0412\u0442\u043e\u0440\u043e\u0435: \u044d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u0432\u0432\u0435\u0434\u0451\u0442 \u0432\u0430\u0441 \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 (\u0438 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435) \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u044b \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0431\u044b\u0447\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0432 Cocoa.<\/p>\n<p>  \u041f\u043e \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0443 \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c:  <\/p>\n<ul>\n<li>\u0447\u0442\u043e \u044d\u0442\u043e \u0437\u0430 \u043f\u0430\u0442\u0442\u0435\u0440\u043d;  <\/li>\n<li>\u0437\u0430\u0447\u0435\u043c \u043e\u043d \u043d\u0443\u0436\u0435\u043d;  <\/li>\n<li>\u043a\u0430\u043a \u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c;  <\/li>\n<li>\u0442\u0438\u043f\u0438\u0447\u043d\u044b\u0435 \u043e\u0448\u0438\u0431\u043a\u0438 \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0430 (\u0435\u0441\u043b\u0438 \u0442\u0430\u043a\u0438\u0435 \u0435\u0441\u0442\u044c).  <\/li>\n<\/ul>\n<p>  \u0422\u0430\u043a \u043a\u0430\u043a \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u044b \u043d\u0435\u043b\u044c\u0437\u044f \u0438\u0437\u0443\u0447\u0430\u0442\u044c \u0431\u0435\u0437 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0438, \u043c\u044b \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u2014 \u043c\u0443\u0437\u044b\u043a\u0430\u043b\u044c\u043d\u0443\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u043a\u0430\u0436\u0435\u0442 \u0432\u0430\u0448\u0438 \u0430\u043b\u044c\u0431\u043e\u043c\u044b \u0438 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043f\u043e \u043d\u0438\u043c. \u0412 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0432\u044b \u043f\u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u0435\u0441\u044c \u0441 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u0438\u0437 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u043e\u0432:<\/p>\n<p>  <b>\u041f\u043e\u0440\u043e\u0436\u0434\u0430\u044e\u0449\u0438\u0435 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u044b<\/b> (creational) \u0434\u0435\u043b\u0430\u044e\u0442 \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0439 \u043e\u0442 \u0441\u043f\u043e\u0441\u043e\u0431\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432:  <\/p>\n<ul>\n<li>\u041e\u0434\u0438\u043d\u043e\u0447\u043a\u0430 (singleton)  <\/li>\n<li>\u0410\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u0430\u044f \u0444\u0430\u0431\u0440\u0438\u043a\u0430 (abstract factory)  <\/li>\n<\/ul>\n<p>  <b>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043d\u044b\u0435 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u044b<\/b> (structural) \u0438\u0449\u0443\u0442 \u043f\u0440\u043e\u0441\u0442\u044b\u0435 \u0441\u043f\u043e\u0441\u043e\u0431\u044b \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0441\u0432\u044f\u0437\u0438 \u043c\u0435\u0436\u0434\u0443 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438:  <\/p>\n<ul>\n<li>MVC (\u0441\u043f\u043e\u0440\u043d\u0430\u044f \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f, \u043d\u0443 \u043f\u0443\u0441\u0442\u044c \u0431\u0443\u0434\u0435\u0442 \u0442\u0443\u0442. <i> \u2014 \u041f\u0440\u0438\u043c. \u043f\u0435\u0440.<\/i>)  <\/li>\n<li>\u0414\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440 (decorator)  <\/li>\n<li>\u0410\u0434\u0430\u043f\u0442\u0435\u0440 (adapter)  <\/li>\n<li>\u0424\u0430\u0441\u0430\u0434 (facade)  <\/li>\n<li>\u041a\u043e\u043c\u043f\u043e\u043d\u043e\u0432\u0449\u0438\u043a (composite)  <\/li>\n<\/ul>\n<p>  <b>\u041f\u043e\u0432\u0435\u0434\u0435\u043d\u0447\u0435\u0441\u043a\u0438\u0435 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u044b<\/b> (behavioral) \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0442 \u0441\u0430\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f, \u00ab\u043e\u0431\u0449\u0435\u043d\u0438\u044f\u00bb \u043c\u0435\u0436\u0434\u0443 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438:  <\/p>\n<ul>\n<li>\u041d\u0430\u0431\u043b\u044e\u0434\u0430\u0442\u0435\u043b\u044c (observer)  <\/li>\n<li>\u0425\u0440\u0430\u043d\u0438\u0442\u0435\u043b\u044c (memento)  <\/li>\n<li>\u0426\u0435\u043f\u043e\u0447\u043a\u0430 \u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0441\u0442\u0438 (chain of responsibility)  <\/li>\n<li>\u041a\u043e\u043c\u0430\u043d\u0434\u0430 (command)  <\/li>\n<\/ul>\n<p>  \u041a \u043a\u043e\u043d\u0446\u0443 \u0441\u0442\u0430\u0442\u044c\u0438 \u043d\u0430\u0448\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a:<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/716\/6ff\/54a\/7166ff54a2d3c18604fc487b3defede0.png\"\/><\/p>\n<h2>\u041d\u0430\u0447\u0438\u043d\u0430\u0435\u043c<\/h2>\n<p>  \u041e\u0442\u043a\u0440\u043e\u0439\u0442\u0435 \u043f\u0440\u043e\u0435\u043a\u0442 <a href=\"https:\/\/github.com\/x128\/BlueLibrary\">BlueLibrary<\/a> \u0432 \u0432\u0430\u0448\u0435\u0439 \u043b\u044e\u0431\u0438\u043c\u043e\u0439 IDE \u0438\u043b\u0438 \u0432 Xcode.<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/5a7\/db3\/1bf\/5a7db31bf0bce757adc8cc8079f647e7.png\"\/><\/p>\n<p>  \u0422\u0430\u043c \u043e\u0431\u044b\u0447\u043d\u044b\u0439 ViewController \u0438 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 HTTP-\u043a\u043b\u0438\u0435\u043d\u0442 \u0441 \u043f\u0443\u0441\u0442\u043e\u0439 \u0438\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0435\u0439.<\/p>\n<p>  <b>\u0417\u043d\u0430\u0435\u0442\u0435 \u043b\u0438 \u0432\u044b?<\/b> \u041a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u044b \u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0435 \u043d\u043e\u0432\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442 \u0432 Xcode \u0438\u043b\u0438 AppCode, \u0432\u0430\u0448 \u043a\u043e\u0434 \u0443\u0436\u0435 \u043f\u043e\u043b\u043e\u043d \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u043e\u0432! MVC, \u00ab\u0434\u0435\u043b\u0435\u0433\u0430\u0442\u00bb, \u00ab\u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u00bb, \u00ab\u0441\u0438\u043d\u0433\u043b\u0442\u043e\u043d\u00bb \u2013 \u0432\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0435 \u0438\u0445 \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u043e! \ud83d\ude42<\/p>\n<p>  \u041f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u043f\u043e\u0433\u0440\u0443\u0437\u0438\u0442\u044c\u0441\u044f \u0432 \u043f\u0435\u0440\u0432\u044b\u0439 \u043f\u0430\u0442\u0442\u0435\u0440\u043d, \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0434\u0432\u0430 \u043a\u043b\u0430\u0441\u0441\u0430 \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0438 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e\u0431 \u0430\u043b\u044c\u0431\u043e\u043c\u0430\u0445.<\/p>\n<p>  <b>Xcode<\/b>: File &gt; New &gt; File\u2026 \u0438\u043b\u0438 \u043d\u0430\u0436\u043c\u0438\u0442\u0435 <b>\u2318N<\/b>.<br \/>  <b>AppCode<\/b>: <b>\u2318N<\/b> &gt; File from Xcode Template\u2026<\/p>\n<p>  \u0412 \u043e\u0442\u043a\u0440\u044b\u0432\u0448\u0435\u043c\u0441\u044f \u0434\u0438\u0430\u043b\u043e\u0433\u0435 \u0432\u044b\u0431\u0435\u0440\u0438\u0442\u0435 \u0432 \u0441\u043f\u0438\u0441\u043a\u0435: <b>iOS &gt; Cocoa Touch &gt; Objective C class<\/b>, \u043d\u0430\u0436\u043c\u0438\u0442\u0435 <b>Next<\/b>. \u041f\u0443\u0441\u0442\u044c \u043a\u043b\u0430\u0441\u0441 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <code>Album<\/code>, \u0438 \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0434\u043a\u043b\u0430\u0441\u0441\u043e\u043c <code>NSObject<\/code>.<\/p>\n<p>  \u041e\u0442\u043a\u0440\u043e\u0439\u0442\u0435 <b>Album.h<\/b> \u0438 \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u043c\u0435\u0436\u0434\u0443 <code>@interface<\/code> \u0438 <code>@end<\/code> \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432 \u0438 \u043e\u0434\u0438\u043d \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f \u043c\u0435\u0442\u043e\u0434\u0430:<\/p>\n<pre><code class=\"cpp\">@property (nonatomic, copy, readonly) NSString * title, * artist, * genre, * coverUrl, * year;  - (id)initWithTitle:(NSString *)title              artist:(NSString *)artist            coverUrl:(NSString *)coverUrl                year:(NSString *)year; <\/code><\/pre>\n<p>  \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435: \u0432\u0441\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0438\u043c\u0435\u044e\u0442 \u0444\u043b\u0430\u0433 <code>readonly<\/code>, \u0442.\u043a. \u043d\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0438\u0445 \u043c\u0435\u043d\u044f\u0442\u044c \u043f\u043e\u0441\u043b\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u0430 <code>Album<\/code>.<\/p>\n<p>  \u042d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u2014 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 \u043e\u0431\u044a\u0435\u043a\u0442\u0430. \u0421\u043e\u0437\u0434\u0430\u0432\u0430\u044f \u043d\u043e\u0432\u044b\u0439 \u0430\u043b\u044c\u0431\u043e\u043c, \u043c\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0451\u043c \u0441\u044e\u0434\u0430 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0430\u043b\u044c\u0431\u043e\u043c\u0430, \u0438\u0441\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044f, URL \u043e\u0431\u043b\u043e\u0436\u043a\u0438 \u0438 \u0433\u043e\u0434 \u0432\u044b\u043f\u0443\u0441\u043a\u0430.<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043e\u0442\u043a\u0440\u043e\u0439\u0442\u0435 <b>Album.m<\/b> \u0438 \u0432\u0441\u0442\u0430\u0432\u044c\u0442\u0435 \u043c\u0435\u0436\u0434\u0443 <code>@implementation<\/code> \u0438 <code>@end<\/code> \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434:<\/p>\n<pre><code class=\"cpp\">- (id)initWithTitle:(NSString *)title              artist:(NSString *)artist            coverUrl:(NSString *)coverUrl                year:(NSString *)year {     self = [super init];     if (self)     {         _title = title;         _artist = artist;         _coverUrl = coverUrl;         _year = year;         _genre = @&quot;Pop&quot;;     }     return self; } <\/code><\/pre>\n<p>  \u0421\u0430\u043c\u0430\u044f \u043e\u0431\u044b\u043a\u043d\u043e\u0432\u0435\u043d\u043d\u0430\u044f \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f.<\/p>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u0435\u0449\u0451 \u043e\u0434\u0438\u043d \u043a\u043b\u0430\u0441\u0441 <code>AlbumView<\/code> \u2014 \u043f\u043e\u0434\u043a\u043b\u0430\u0441\u0441 <code>UIView<\/code>.<\/p>\n<p>  \u0412 <b>AlbumView.h<\/b> \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u043c\u0435\u0436\u0434\u0443 <code>@interface<\/code> \u0438 <code>@end<\/code> \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f \u043c\u0435\u0442\u043e\u0434\u0430:<\/p>\n<pre><code class=\"cpp\">- (id)initWithFrame:(CGRect)frame          albumCover:(NSString *)albumCover; <\/code><\/pre>\n<p>  \u0410 \u0432 <b>AlbumView.m<\/b> \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u0435 \u043a\u043e\u0434 \u043c\u0435\u0436\u0434\u0443 <code>@implementation<\/code> \u0438 <code>@end<\/code> \u043d\u0430 \u0432\u043e\u0442 \u044d\u0442\u043e\u0442:<\/p>\n<pre><code class=\"cpp\">@implementation AlbumView {     UIImageView * coverImage;     UIActivityIndicatorView * indicator; }  - (id)initWithFrame:(CGRect)frame          albumCover:(NSString *)albumCover {     self = [super initWithFrame:frame];     if (self)     {         \/\/ \u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0447\u0451\u0440\u043d\u044b\u0439 \u0444\u043e\u043d:         self.backgroundColor = [UIColor blackColor];          \/\/ \u0421\u043e\u0437\u0434\u0430\u0451\u043c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0441 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u043c \u043e\u0442\u0441\u0442\u0443\u043f\u043e\u043c - 5 \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439 \u043e\u0442 \u043a\u0440\u0430\u044f:         coverImage = [[UIImageView alloc] initWithFrame:CGRectMake(5, 5, frame.size.width-10, frame.size.height-10)];         [self addSubview:coverImage];          \/\/ \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0438\u043d\u0434\u0438\u043a\u0430\u0442\u043e\u0440 \u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u0438:         indicator = [[UIActivityIndicatorView alloc] init];         indicator.center = self.center;         indicator.activityIndicatorViewStyle = UIActivityIndicatorViewStyleWhiteLarge;         [indicator startAnimating];         [self addSubview:indicator];     }     return self; }   @end <\/code><\/pre>\n<p>  \u041f\u0435\u0440\u0432\u043e\u0435, \u0447\u0442\u043e \u0432\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c \u2014 \u0442\u0443\u0442 \u0435\u0441\u0442\u044c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430: <code>coverImage<\/code>. \u042d\u0442\u0430 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0438\u0437 \u0441\u0435\u0431\u044f \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0441 \u043e\u0431\u043b\u043e\u0436\u043d\u043e\u0439 \u0430\u043b\u044c\u0431\u043e\u043c\u0430. \u0412\u0442\u043e\u0440\u0430\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f <code>indicator<\/code> \u2014 \u044d\u0442\u043e \u0438\u043d\u0434\u0438\u043a\u0430\u0442\u043e\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043a\u0440\u0443\u0442\u0438\u0442\u0441\u044f, \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0430\u044f \u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c, \u043f\u043e\u043a\u0430 \u043e\u0431\u043b\u043e\u0436\u043a\u0430 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u0442\u0441\u044f.<\/p>\n<p>  \u041f\u043e\u0447\u0435\u043c\u0443 \u044d\u0442\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u044b \u0432 \u0444\u0430\u0439\u043b\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 (<code>*.m<\/code>), \u0430 \u043d\u0435 \u0432 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u0447\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435 (<code>*.h<\/code>)? \u041f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0434\u0440\u0443\u0433\u0438\u043c \u043a\u043b\u0430\u0441\u0441\u0430\u043c (\u0432\u043d\u0435 <code>AlbumView<\/code>) \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0437\u043d\u0430\u0442\u044c \u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u0438\u0438 \u044d\u0442\u0438\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445, \u0442.\u043a. \u043e\u043d\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u043d\u0443\u0442\u0440\u0438 \u043a\u043b\u0430\u0441\u0441\u0430. \u042d\u0442\u043e\u0442 \u043c\u043e\u043c\u0435\u043d\u0442 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0447\u0440\u0435\u0437\u0432\u044b\u0447\u0430\u0439\u043d\u043e \u0432\u0430\u0436\u043d\u044b\u043c, \u0435\u0441\u043b\u0438 \u0432\u044b \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 (\u0438\u043b\u0438 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a) \u0434\u043b\u044f \u0434\u0440\u0443\u0433\u0438\u0445 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432.<\/p>\n<p>  \u0412\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u0435 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 (\u2318B) \u2014 \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430. \u0412\u0441\u0451 \u0432 \u043f\u043e\u0440\u044f\u0434\u043a\u0435? \u0422\u043e\u0433\u0434\u0430 \u043f\u0440\u0438\u0433\u043e\u0442\u043e\u0432\u044c\u0442\u0435\u0441\u044c: \u0432\u0430\u0448 \u043f\u0435\u0440\u0432\u044b\u0439 \u043f\u0430\u0442\u0442\u0435\u0440\u043d!<\/p>\n<h2>MVC \u2014 \u043a\u043e\u0440\u043e\u043b\u044c \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u043e\u0432<\/h2>\n<p>  <img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/092\/650\/f12\/092650f123cc2693c3e0906fbb6df1c2.png\"\/><\/p>\n<p>  \u041c\u043e\u0434\u0435\u043b\u044c\u2014\u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u2014\u041a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 (Model\u2014View\u2014Controller \u0438\u043b\u0438 \u043f\u0440\u043e\u0441\u0442\u043e MVC) \u2014 \u043e\u0434\u043d\u0430 \u0438\u0437 \u043e\u0441\u043d\u043e\u0432 Cocoa \u0438, \u043d\u0435\u0441\u043e\u043c\u043d\u0435\u043d\u043d\u043e, \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0447\u0430\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0439 \u043f\u0430\u0442\u0442\u0435\u0440\u043d. \u041e\u043d \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u0446\u0438\u0440\u0443\u0435\u0442 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0441\u043e\u0433\u043b\u0430\u0441\u043d\u043e \u0438\u0445 \u0440\u043e\u043b\u0438 \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u0438 \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u0447\u0438\u0441\u0442\u043e\u043c\u0443 \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u044e \u043a\u043e\u0434\u0430 (\u0447\u0442\u043e \u044d\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u2014 \u043e\u0431\u0441\u0443\u0434\u0438\u043c \u043d\u0438\u0436\u0435).<\/p>\n<p>  \u0422\u0440\u0438 \u0440\u043e\u043b\u0438:<\/p>\n<ul>\n<li><b>\u041c\u043e\u0434\u0435\u043b\u044c<\/b> (model) \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u044b \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u044f\u0446\u0438\u0439 \u043d\u0430\u0434 \u043d\u0438\u043c\u0438. \u0412 \u043d\u0430\u0448\u0435\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u043c\u043e\u0434\u0435\u043b\u044c\u044e \u0431\u0443\u0434\u0435\u0442 \u043a\u043b\u0430\u0441\u0441 <code>Album<\/code>.  <\/li>\n<li><b>\u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435<\/b> (view), \u0438\u043d\u043e\u0433\u0434\u0430 \u0433\u043e\u0432\u043e\u0440\u044f\u0442 \u00ab\u0432\u0438\u0434\u00bb \u2014 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u0432\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043c\u043e\u0434\u0435\u043b\u0438, \u0430 \u0442\u0430\u043a\u0436\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043c\u043e\u0436\u0435\u0442 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c. \u041a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e, \u044d\u0442\u043e UIView \u0438 \u0435\u0433\u043e \u043f\u043e\u0434\u043a\u043b\u0430\u0441\u0441\u044b. \u0412 \u043d\u0430\u0448\u0435\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u2014 \u044d\u0442\u043e <code>AlbumView<\/code>.  <\/li>\n<li><b>\u041a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440<\/b> (controller) \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0438\u0440\u0443\u0435\u0442 \u0432\u0441\u044e \u0440\u0430\u0431\u043e\u0442\u0443. \u0418\u043c\u0435\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0434\u0430\u043d\u043d\u044b\u043c \u043c\u043e\u0434\u0435\u043b\u0438, \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442 \u0438\u0445 \u0432 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f\u0445, \u043f\u043e\u0434\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u0438 \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u0438\u0440\u0443\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u043c\u0438. \u041a\u0430\u043a\u043e\u0439 \u043a\u043b\u0430\u0441\u0441 \u0443 \u043d\u0430\u0441 \u0431\u0443\u0434\u0435\u0442 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u043e\u043c? \u041f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e, <code>ViewController<\/code>.  <\/li>\n<\/ul>\n<p>  \u041f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0430 MVC \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0432 \u0432\u0430\u0448\u0435\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u043a\u0430\u0436\u0434\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 \u043f\u043e\u043f\u0430\u0434\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u043e\u0434\u043d\u0443 \u0438\u0437 \u044d\u0442\u0438\u0445 \u0433\u0440\u0443\u043f\u043f.<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/0a2\/a5c\/fbd\/0a2a5cfbd5e289e13e451222731608fd.png\"\/>  <\/p>\n<ul>\n<li>\u041c\u043e\u0434\u0435\u043b\u044c \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u044f\u0435\u0442 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u043e \u043b\u044e\u0431\u044b\u0445 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f\u0445 \u0432 \u0434\u0430\u043d\u043d\u044b\u0445. \u0412 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c, \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f\u0445.  <\/li>\n<li>\u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u044f\u0435\u0442 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f. \u041a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u043f\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442 \u043c\u043e\u0434\u0435\u043b\u044c \u0438\u043b\u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0448\u0435\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435.  <\/li>\n<\/ul>\n<p>  \u0417\u0430\u0447\u0435\u043c \u044d\u0442\u043e \u0432\u0441\u0451? \u041f\u043e\u0447\u0435\u043c\u0443 \u0431\u044b \u043d\u0435 \u0432\u044b\u043a\u0438\u043d\u0443\u0442\u044c \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440, \u0430 \u043c\u043e\u0434\u0435\u043b\u044c \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0438\u0442\u044c \u0441 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u0432 \u043e\u0434\u0438\u043d \u043a\u043b\u0430\u0441\u0441? \u0411\u0443\u0434\u0435\u0442 \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u043f\u0440\u043e\u0449\u0435!<\/p>\n<p>  \u0412\u043e\u043f\u0440\u043e\u0441 \u0441\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043a \u0434\u0432\u0443\u043c (\u0432\u0437\u0430\u0438\u043c\u043e\u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u043c) \u0432\u0435\u0449\u0430\u043c:  <\/p>\n<ol>\n<li>\u0420\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043a\u043e\u0434\u0430;<\/li>\n<li>\u041f\u0435\u0440\u0441\u043f\u0435\u043a\u0442\u0438\u0432\u0430 \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u043e\u0434\u0430.<\/li>\n<\/ol>\n<p>  \u0412 \u0438\u0434\u0435\u0430\u043b\u0435, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043e\u0442\u0434\u0435\u043b\u0435\u043d\u043e \u043e\u0442 \u043c\u043e\u0434\u0435\u043b\u0438. \u0415\u0441\u043b\u0438 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043d\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043c\u043e\u0434\u0435\u043b\u0438, \u043e\u043d\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u043e \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u043d\u043e \u0441 \u0434\u0440\u0443\u0433\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u044c\u044e, \u0434\u043b\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0438\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>  \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 \u0431\u0443\u0434\u0443\u0449\u0435\u043c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0437\u0430\u0445\u043e\u0442\u0435\u0442\u044c \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0444\u0438\u043b\u044c\u043c\u044b \u0438\u043b\u0438 \u043a\u043d\u0438\u0433\u0438 \u0432 \u043d\u0430\u0448\u0443 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443. \u041c\u044b \u0441\u043c\u043e\u0436\u0435\u043c \u043f\u043e-\u043f\u0440\u0435\u0436\u043d\u0435\u043c\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>AlbumView<\/code> \u0434\u043b\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u00ab\u0444\u0438\u043b\u044c\u043c\u00bb \u0438 \u00ab\u043a\u043d\u0438\u0433\u0430\u00bb! \u0410 \u0435\u0441\u043b\u0438 \u043c\u044b \u0437\u0430\u0445\u043e\u0442\u0438\u043c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u0434\u0440\u0443\u0433\u043e\u0439 \u043f\u0440\u043e\u0435\u043a\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u0434\u0435\u043b\u043e \u0441 \u0430\u043b\u044c\u0431\u043e\u043c\u0430\u043c\u0438, \u043c\u044b \u0441\u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u043d\u0451\u043c \u043a\u043b\u0430\u0441\u0441 <code>Album<\/code> \u2014 \u044d\u0442\u043e \u043c\u043e\u0434\u0435\u043b\u044c, \u043d\u0435 \u0437\u0430\u0432\u0438\u0441\u044f\u0449\u0430\u044f \u043e\u0442 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f. \u0412 \u044d\u0442\u043e\u043c \u2014 \u0441\u0438\u043b\u0430 MVC!<\/p>\n<h3>\u041a\u0430\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0430\u0442\u0442\u0435\u0440\u043d MVC<\/h3>\n<p>  1. \u0423\u0431\u0435\u0434\u0438\u0442\u0435\u0441\u044c, \u0447\u0442\u043e \u043a\u0430\u0436\u0434\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043c\u043e\u0434\u0435\u043b\u044c\u044e, \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u043e\u043c \u0438\u043b\u0438 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c. \u041e\u0434\u0438\u043d \u043a\u043b\u0430\u0441\u0441 \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0441\u043e\u0432\u043c\u0435\u0449\u0430\u0442\u044c \u0434\u0432\u0435 \u0440\u043e\u043b\u0438! \u041c\u044b \u0443\u0436\u0435 \u0441\u0434\u0435\u043b\u0430\u043b\u0438 \u043f\u0435\u0440\u0432\u044b\u0439 \u0448\u0430\u0433, \u0441\u043e\u0437\u0434\u0430\u0432 \u0434\u0432\u0430 \u043a\u043b\u0430\u0441\u0441\u0430: <code>Album<\/code> \u0438 <code>AlbumView<\/code>.<\/p>\n<p>  2. <i>\u0417\u0430\u0431\u0443\u0434\u044c\u0442\u0435 \u0442\u043e\u0442 \u0443\u0436\u0430\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b \u0432\u0438\u0434\u0435\u043b\u0438 \u043d\u0430 developer.apple.com! \u0414\u0430-\u0434\u0430, \u0442\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b, \u0433\u0434\u0435 <code>ViewController<\/code>&#8216;\u044b \u0438\u0433\u0440\u0430\u044e\u0442 \u0434\u0432\u0435-\u0442\u0440\u0438 \u0440\u043e\u043b\u0438 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e. \u2014 \u041f\u0440\u0438\u043c. \u043f\u0435\u0440.<\/i><\/p>\n<p>  3. \u0421\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0442\u0440\u0438 \u0433\u0440\u0443\u043f\u043f\u044b \u2014 <code>Model<\/code>, <code>View<\/code> \u0438 <code>Controller<\/code>:<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/af6\/158\/4bb\/af61584bbabae81220d32d3c2d4866e2.png\"\/><\/p>\n<p>  \u041a\u0430\u043a \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c:<\/p>\n<ol>\n<li><b>File &gt; New &gt; Group<\/b> (\u0438\u043b\u0438 \u0441 \u043a\u043b\u0430\u0432\u0438\u0430\u0442\u0443\u0440\u044b: \u0432 Xcode <b>\u2318\u2325N<\/b>, \u0432 AppCode <b>\u2318\u2325N &gt; Group<\/b>), \u043d\u0430\u0437\u043e\u0432\u0438\u0442\u0435 \u0433\u0440\u0443\u043f\u043f\u0443 <code>Model<\/code>. \u041f\u0440\u043e\u0434\u0435\u043b\u0430\u0439\u0442\u0435 \u0442\u0443 \u0436\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e \u0434\u043b\u044f <code>Controller<\/code> \u0438 <code>View<\/code>.  <\/li>\n<li>\u041f\u0435\u0440\u0435\u0442\u0430\u0449\u0438\u0442\u0435 <b>Album.h<\/b> \u0438 <b>Album.m<\/b> \u0432 \u0433\u0440\u0443\u043f\u043f\u0443 <code>Model<\/code>.<br \/>  \u041f\u0435\u0440\u0435\u0442\u0430\u0449\u0438\u0442\u0435 <b>AlbumView.h<\/b> \u0438 <b>AlbumView.m<\/b> \u0432 \u0433\u0440\u0443\u043f\u043f\u0443 <code>View<\/code>.<br \/>  \u041f\u0435\u0440\u0435\u0442\u0430\u0449\u0438\u0442\u0435 <b>ViewController.h<\/b> \u0438 <b>ViewController.m<\/b> \u0432 \u0433\u0440\u0443\u043f\u043f\u0443 <code>Controller<\/code>.  <\/li>\n<\/ol>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u0448 \u043f\u0440\u043e\u0435\u043a\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u043b\u0443\u0447\u0448\u0435 \u0431\u0435\u0437 \u044d\u0442\u0438\u0445\u2026 \u0444\u0430\u0439\u043b\u043e\u0432, \u043f\u043b\u0430\u0432\u0430\u044e\u0449\u0438\u0445 \u0432\u043e\u043a\u0440\u0443\u0433. \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0434\u0440\u0443\u0433\u0438\u0435 \u0433\u0440\u0443\u043f\u043f\u044b \u0438 \u043a\u043b\u0430\u0441\u0441\u044b, \u043d\u043e \u0433\u043b\u0430\u0432\u043d\u043e\u0435 \u2014 \u0432\u043e\u0442 \u044d\u0442\u0438 \u0442\u0440\u0438 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0438.<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c, \u043a\u043e\u0433\u0434\u0430 \u0432\u0430\u0448\u0438 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u043e\u0432\u0430\u043d\u044b, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0433\u0434\u0435-\u0442\u043e \u0432\u0437\u044f\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u0430\u043b\u044c\u0431\u043e\u043c\u043e\u0432. \u041c\u044b \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c API-\u043a\u043b\u0430\u0441\u0441, \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043e\u0431\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u043a \u0434\u0430\u043d\u043d\u044b\u043c \u0438\u0437 \u043b\u044e\u0431\u043e\u0433\u043e \u043c\u0435\u0441\u0442\u0430 \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u044b \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u043c \u043a \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c\u0443 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0443 \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f:<\/p>\n<h2>\u041e\u0434\u0438\u043d\u043e\u0447\u043a\u0430 (\u0441\u0438\u043d\u0433\u043b\u0442\u043e\u043d)<\/h2>\n<p>  \u041f\u0430\u0442\u0442\u0435\u0440\u043d \u00ab\u043e\u0434\u0438\u043d\u043e\u0447\u043a\u0430\u00bb \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u0442, \u0447\u0442\u043e \u0432\u043e \u0432\u0441\u0451\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430. \u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u0430\u044f \u0442\u043e\u0447\u043a\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u044d\u0442\u043e\u043c\u0443 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0443. \u041e\u0431\u044b\u0447\u043d\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u043e\u0442\u043b\u043e\u0436\u0435\u043d\u043d\u0430\u044f \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f: \u044d\u0442\u043e\u0442 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0441\u044f, \u043a\u043e\u0433\u0434\u0430 \u043e\u043d \u043d\u0443\u0436\u0435\u043d \u0432 \u043f\u0435\u0440\u0432\u044b\u0439 \u0440\u0430\u0437.<\/p>\n<p>  <i><b>\u0417\u043d\u0430\u0435\u0442\u0435 \u043b\u0438 \u0432\u044b?<\/b> Apple \u0448\u0438\u0440\u043e\u043a\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440: <code>[NSUserDefaults standardUserDefaults]<\/code>, <code>[UIApplication sharedApplication]<\/code>, <code>[UIScreen mainScreen]<\/code>, <code>[NSFileManager defaultManager]<\/code> \u2014 \u043a\u0430\u0436\u0434\u044b\u0439 \u0438\u0437 \u044d\u0442\u0438\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043e\u0431\u044a\u0435\u043a\u0442-\u0441\u0438\u043d\u0433\u043b\u0442\u043e\u043d.<\/i><\/p>\n<p>  \u0412\u044b \u0441\u043f\u0440\u043e\u0441\u0438\u0442\u0435, \u0437\u0430\u0447\u0435\u043c \u0431\u0435\u0441\u043f\u043e\u043a\u043e\u0438\u0442\u044c\u0441\u044f \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u0433\u0434\u0435-\u0442\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0434\u0432\u0430 \u0438\u043b\u0438 \u0431\u043e\u043b\u044c\u0448\u0435 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u043e\u0432 \u043a\u043b\u0430\u0441\u0441\u0430. \u041f\u043e\u0447\u0435\u043c\u0443 \u043d\u0435 \u0431\u043e\u043b\u044c\u0448\u0435 \u043e\u0434\u043d\u043e\u0433\u043e \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430? \u041f\u0430\u043c\u044f\u0442\u044c \u043d\u044b\u043d\u0447\u0435 \u0434\u0435\u0448\u0451\u0432\u0430\u044f, \u0440\u0430\u0437\u0432\u0435 \u043d\u0435\u0442?<\/p>\n<p>  \u0415\u0441\u0442\u044c \u0442\u0430\u043a\u0438\u0435 \u0441\u043b\u0443\u0447\u0430\u0438, \u0433\u0434\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0438\u043c\u0435\u0442\u044c \u0440\u043e\u0432\u043d\u043e \u043e\u0434\u0438\u043d \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043a\u043b\u0430\u0441\u0441\u0430. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432\u0430\u043c \u043d\u0438 \u043a \u0447\u0435\u043c\u0443 \u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u043e\u0432 \u043a\u043b\u0430\u0441\u0441\u0430 <code>Logger<\/code> (\u0442\u043e\u043b\u044c\u043a\u043e \u0435\u0441\u043b\u0438 \u0432\u044b \u043d\u0435 \u043f\u0438\u0448\u0435\u0442\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437\u043d\u044b\u0445 \u043b\u043e\u0433\u043e\u0432 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e). \u0418\u043b\u0438 \u043a\u043b\u0430\u0441\u0441 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u043a \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u043e\u0439 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438: \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u043b\u0443\u0447\u0448\u0435 \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0442\u044c \u043f\u043e\u0442\u043e\u043a\u043e-\u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u044b\u0439 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u043c\u0443 \u043e\u0431\u0449\u0435\u043c\u0443 \u0440\u0435\u0441\u0443\u0440\u0441\u0443 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043a \u0444\u0430\u0439\u043b\u0443 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a), \u0447\u0435\u043c \u0438\u043c\u0435\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u043e\u0432, \u043c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u0443\u044e\u0449\u0438\u0445 \u0444\u0430\u0439\u043b \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e.<\/p>\n<h3>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0430 \u00ab\u043e\u0434\u0438\u043d\u043e\u0447\u043a\u0430\u00bb<\/h3>\n<p>  \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u0442\u0435 \u0441\u0445\u0435\u043c\u0443:<br \/>  <img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/851\/848\/7c1\/8518487c1a4b150c4d3105e9f0654f13.png\"\/><br \/>  \u0423 \u043a\u043b\u0430\u0441\u0441\u0430 <code>Logger<\/code> \u0435\u0441\u0442\u044c \u043e\u0434\u043d\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e <code>instance<\/code> (\u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440) \u0438 \u0434\u0432\u0430 \u043c\u0435\u0442\u043e\u0434\u0430: <code>sharedInstance()<\/code> \u0438 <code>init()<\/code>.<\/p>\n<p>  \u041a\u043e\u0433\u0434\u0430 \u043a\u043b\u0438\u0435\u043d\u0442 \u0432\u043f\u0435\u0440\u0432\u044b\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u043c\u0435\u0442\u043e\u0434 <code>sharedInstance()<\/code>, \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e <code>instance<\/code> \u0435\u0449\u0451 \u043d\u0435 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043e, \u0442\u043e\u0433\u0434\u0430 \u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0441\u044f \u043d\u043e\u0432\u044b\u0439 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043a\u043b\u0430\u0441\u0441\u0430 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u043d\u0435\u0433\u043e.<\/p>\n<p>  \u041a\u043e\u0433\u0434\u0430 \u043c\u044b \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0440\u0430\u0437 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c <code>sharedInstance()<\/code>, \u043d\u0430\u043c \u0441\u0440\u0430\u0437\u0443 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f <code>instance<\/code> \u0431\u0435\u0437 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438. \u0422\u0430\u043a\u0430\u044f \u0441\u0445\u0435\u043c\u0430 \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u0442 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u0438\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u043e\u0433\u043e \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430 \u0437\u0430 \u0432\u0441\u0451 \u0432\u0440\u0435\u043c\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b.<\/p>\n<p>  \u041c\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u044d\u0442\u043e\u0442 \u043f\u0430\u0442\u0442\u0435\u0440\u043d: \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0441\u0438\u043d\u0433\u043b\u0442\u043e\u043d \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0432\u0441\u0435\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0430\u043b\u044c\u0431\u043e\u043c\u0430.<\/p>\n<p>  \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0435\u0441\u0442\u044c \u0433\u0440\u0443\u043f\u043f\u0430 \u043f\u043e\u0434 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c <code>API<\/code>. \u0422\u0443\u0434\u0430 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0442\u044c \u043a\u043b\u0430\u0441\u0441\u044b, \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0435 \u0441\u0435\u0440\u0432\u0438\u0441\u044b \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u0412 \u044d\u0442\u043e\u0439 \u0433\u0440\u0443\u043f\u043f\u0435 \u0441\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u043a\u043b\u0430\u0441\u0441 \u0438\u0437 \u0448\u0430\u0431\u043b\u043e\u043d\u0430 <b>iOS &gt; Cocoa Touch &gt; Objective-C class<\/b>, \u043f\u043e\u0434\u043a\u043b\u0430\u0441\u0441 <code>NSObject<\/code>, \u0438 \u043d\u0430\u0437\u043e\u0432\u0438\u0442\u0435 \u0435\u0433\u043e <code>LibraryAPI<\/code>.<\/p>\n<p>  \u041e\u0442\u043a\u0440\u043e\u0439\u0442\u0435 <b>LibraryAPI.h<\/b> \u0438 \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u0435 \u0435\u0433\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<pre><code class=\"cpp\">@interface LibraryAPI : NSObject  + (LibraryAPI *)sharedInstance;  @end <\/code><\/pre>\n<p>  \u041f\u0435\u0440\u0435\u0439\u0434\u0438\u0442\u0435 \u043a <b>LibraryAPI.m<\/b> \u0438 \u0432\u0441\u0442\u0430\u0432\u044c\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043c\u0435\u0442\u043e\u0434 \u043f\u043e\u0441\u043b\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 <code>@implentation<\/code>:<\/p>\n<pre><code class=\"cpp\">+ (LibraryAPI *)sharedInstance {     \/\/ 1     static LibraryAPI * _sharedInstance = nil;      \/\/ 2     static dispatch_once_t oncePredicate;      \/\/ 3     dispatch_once(&oncePredicate, ^{         _sharedInstance = [[LibraryAPI alloc] init];     });     return _sharedInstance; } <\/code><\/pre>\n<p>  \u0412 \u044d\u0442\u043e\u043c \u043a\u043e\u0440\u043e\u0442\u043a\u043e\u043c \u043c\u0435\u0442\u043e\u0434\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043c\u043d\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0433\u043e:<\/p>\n<ol>\n<li>\u041e\u0431\u044a\u044f\u0432\u043b\u044f\u0435\u043c \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044f \u043d\u0430 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043a\u043b\u0430\u0441\u0441\u0430 (\u0435\u0451 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u043e \u0438\u0437 \u043d\u0430\u0448\u0435\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430).  <\/li>\n<li>\u041e\u0431\u044a\u044f\u0432\u043b\u044f\u0435\u043c \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e dispatch_once_t, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0442, \u0447\u0442\u043e \u043a\u043e\u0434 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u0440\u0430\u0437.  <\/li>\n<li>\u041f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 Grand Central Dispatch (GCD) \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430 <code>LibraryAPI<\/code>. \u0412 \u044d\u0442\u043e\u043c \u0441\u0443\u0442\u044c \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0430 \u00ab\u043e\u0434\u0438\u043d\u043e\u0447\u043a\u0430\u00bb: \u0431\u043b\u043e\u043a \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u0441\u044f \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e.  <\/li>\n<\/ol>\n<p>  \u041f\u0440\u0438 \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e\u043c \u0432\u044b\u0437\u043e\u0432\u0435 <code>sharedInstance()<\/code> \u043a\u043e\u0434 \u0432\u043d\u0443\u0442\u0440\u0438 \u0431\u043b\u043e\u043a\u0430 <code>dispatch_once<\/code> \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d (\u0442.\u043a. \u043e\u043d \u0443\u0436\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d \u0440\u0430\u043d\u0435\u0435), \u0438 \u0432\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0435 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0439 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0439 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 <code>LibraryAPI<\/code>.<\/p>\n<p>  <b>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435.<\/b> \u0427\u0442\u043e\u0431\u044b \u0443\u0437\u043d\u0430\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435 \u043e <a href=\"http:\/\/ru.wikipedia.org\/wiki\/Grand_Central_Dispatch\">GCD<\/a> \u0438 \u043e \u0435\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0438, \u0430\u0432\u0442\u043e\u0440 \u0441\u0442\u0430\u0442\u044c\u0438 \u0441\u043e\u0432\u0435\u0442\u0443\u0435\u0442 \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b\u044b \u043d\u0430 \u0430\u043d\u0433\u043b\u0438\u0439\u0441\u043a\u043e\u043c: <a href=\"http:\/\/www.raywenderlich.com\/4295\/multithreading-and-grand-central-dispatch-on-ios-for-beginners-tutorial\">Multithreading and Grand Central Dispatch<\/a> \u0438 <a href=\"http:\/\/www.raywenderlich.com\/9328\/creating-a-diner-app-using-blocks-part-1\">How To Use Blocks<\/a>.<\/p>\n<p>  \u0418\u0442\u0430\u043a, \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0441\u0438\u043d\u0433\u043b\u0442\u043e\u043d \u2014 \u043e\u0442\u043f\u0440\u0430\u0432\u043d\u0430\u044f \u0442\u043e\u0447\u043a\u0430 \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0430\u043b\u044c\u0431\u043e\u043c\u0430\u043c\u0438. \u0421\u0434\u0435\u043b\u0430\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0448\u0430\u0433: \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043a\u043b\u0430\u0441\u0441 \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043d\u0430\u0448\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>  \u0412 \u0433\u0440\u0443\u043f\u043f\u0435 <code>API<\/code> \u0441\u043e\u0437\u0434\u0430\u0451\u043c \u043d\u043e\u0432\u044b\u0439 \u043a\u043b\u0430\u0441\u0441: <b>iOS &gt; Cocoa Touch &gt; Objective-C class<\/b>, \u043f\u043e\u0434\u043a\u043b\u0430\u0441\u0441 <code>NSObject<\/code>, \u0430 \u043d\u0430\u0437\u043e\u0432\u0451\u043c \u0435\u0433\u043e <code>PersistencyManager<\/code>.<\/p>\n<p>  \u041e\u0442\u043a\u0440\u043e\u0439\u0442\u0435 <b>PersistencyManager.h<\/b> \u0438 \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0441\u0442\u0440\u043e\u0447\u043a\u0443 \u0432 \u043d\u0430\u0447\u0430\u043b\u043e \u0444\u0430\u0439\u043b\u0430:<\/p>\n<pre><code class=\"cpp\">#import &quot;Album.h&quot; <\/code><\/pre>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434 \u043f\u043e\u0441\u043b\u0435 <code>@interface<\/code>:<\/p>\n<pre><code class=\"cpp\">- (NSArray *)getAlbums; - (void)addAlbum:(Album *)album atIndex:(NSUInteger)index; - (void)deleteAlbumAtIndex:(NSUInteger)index; <\/code><\/pre>\n<p>  \u042d\u0442\u043e \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f\u044b \u0442\u0440\u0451\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0430\u043b\u044c\u0431\u043e\u043c\u043e\u0432.<\/p>\n<p>  \u041e\u0442\u043a\u0440\u043e\u0439\u0442\u0435 <b>PersistencyManager.m<\/b> \u0438 \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u043a\u043e\u0434 \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043f\u0435\u0440\u0435\u0434 \u0441\u0442\u0440\u043e\u0447\u043a\u043e\u0439 <code>@implementation<\/code>:<\/p>\n<pre><code class=\"cpp\">@interface PersistencyManager () {     NSMutableArray * albums; \/\/ \u041c\u0430\u0441\u0441\u0438\u0432 \u0432\u0441\u0435\u0445 \u0430\u043b\u044c\u0431\u043e\u043c\u043e\u0432 } @end <\/code><\/pre>\n<p>  \u042d\u0442\u043e \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u0430 (class extension) \u2014 \u0435\u0449\u0451 \u043e\u0434\u0438\u043d \u0441\u043f\u043e\u0441\u043e\u0431 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0437\u0430\u043a\u0440\u044b\u0442\u044b\u0435 (private) \u043c\u0435\u0442\u043e\u0434\u044b \u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043a \u043a\u043b\u0430\u0441\u0441\u0443 \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0447\u0442\u043e\u0431\u044b \u0432\u043d\u0435\u0448\u043d\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u044b \u043d\u0435 \u0437\u043d\u0430\u043b\u0438 \u043e \u043d\u0438\u0445. \u0417\u0434\u0435\u0441\u044c \u043c\u044b \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u0435\u043c \u043c\u0430\u0441\u0441\u0438\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0430\u043b\u044c\u0431\u043e\u043c\u043e\u0432. \u042d\u0442\u043e\u0442 \u043c\u0430\u0441\u0441\u0438\u0432 \u2014 \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c\u044b\u0439 (mutable), \u0442\u0430\u043a \u0447\u0442\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043b\u0435\u0433\u043a\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0438 \u0443\u0434\u0430\u043b\u044f\u0442\u044c \u0430\u043b\u044c\u0431\u043e\u043c\u044b.<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043a\u043b\u0430\u0441\u0441\u0430 <code>PersistencyManager<\/code> \u043f\u043e\u0441\u043b\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 <code>@implementation<\/code>:<\/p>\n<pre><code class=\"cpp\">- (id)init {     self = [super init];     if (self)     {         albums = [NSMutableArray arrayWithArray:                 @[[[Album alloc] initWithTitle:@&quot;Best of Bowie&quot;                                         artist:@&quot;David Bowie&quot;                                       coverUrl:@&quot;http:\/\/www.coversproject.com\/static\/thumbs\/album\/album_david%20bowie_best%20of%20bowie.png&quot;                                           year:@&quot;1992&quot;],                          [[Album alloc] initWithTitle:@&quot;It's My Life&quot;                                               artist:@&quot;No Doubt&quot;                                             coverUrl:@&quot;http:\/\/www.coversproject.com\/static\/thumbs\/album\/album_no%20doubt_its%20my%20life%20%20bathwater.png&quot;                                                 year:@&quot;2003&quot;],                          [[Album alloc] initWithTitle:@&quot;Nothing Like The Sun&quot;                                               artist:@&quot;Sting&quot;                                             coverUrl:@&quot;http:\/\/www.coversproject.com\/static\/thumbs\/album\/album_sting_nothing%20like%20the%20sun.png&quot;                                                 year:@&quot;1999&quot;],                          [[Album alloc] initWithTitle:@&quot;Staring at the Sun&quot;                                               artist:@&quot;U2&quot;                                             coverUrl:@&quot;http:\/\/www.coversproject.com\/static\/thumbs\/album\/album_u2_staring%20at%20the%20sun.png&quot;                                                 year:@&quot;2000&quot;],                          [[Album alloc] initWithTitle:@&quot;American Pie&quot;                                               artist:@&quot;Madonna&quot;                                             coverUrl:@&quot;http:\/\/www.coversproject.com\/static\/thumbs\/album\/album_madonna_american%20pie.png&quot;                                                 year:@&quot;2000&quot;]]];     }     return self; } <\/code><\/pre>\n<p>  \u0412 \u043c\u0435\u0442\u043e\u0434\u0435 <code>init<\/code> \u043c\u044b \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u043c \u043c\u0430\u0441\u0441\u0438\u0432 \u0438\u0437 \u043f\u044f\u0442\u0438 \u0430\u043b\u044c\u0431\u043e\u043c\u043e\u0432 \u0434\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u0430 (\u0435\u0441\u043b\u0438 \u0432\u0430\u043c \u043d\u0435\u0447\u0435\u0433\u043e \u0434\u0435\u043b\u0430\u0442\u044c, \u043c\u043e\u0436\u0435\u0442\u0435 \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u0438\u0445 \u043d\u0430 \u0441\u0432\u043e\u044e \u043b\u044e\u0431\u0438\u043c\u0443\u044e \u043c\u0443\u0437\u044b\u043a\u0443).<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0442\u0440\u0438 \u043c\u0435\u0442\u043e\u0434\u0430 \u0432 <b>PersistencyManager.m<\/b>:<\/p>\n<pre><code class=\"cpp\">- (NSArray *)getAlbums {     return albums; }  - (void)addAlbum:(Album *)album atIndex:(NSUInteger)index {     if (albums.count &gt;= index)         [albums insertObject:album atIndex:index];     else         [albums addObject:album]; }  - (void)deleteAlbumAtIndex:(NSUInteger)index {     [albums removeObjectAtIndex:index]; } <\/code><\/pre>\n<p>  \u042d\u0442\u0438 \u043f\u0440\u043e\u0441\u0442\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c, \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0438 \u0443\u0434\u0430\u043b\u044f\u0442\u044c \u0430\u043b\u044c\u0431\u043e\u043c\u044b.<\/p>\n<p>  \u041f\u043e\u0441\u0442\u0440\u043e\u0439\u0442\u0435 \u043f\u0440\u043e\u0435\u043a\u0442 (\u2318B), \u043f\u0440\u043e\u0441\u0442\u043e \u0447\u0442\u043e\u0431\u044b \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u043e\u043d \u200b\u200b\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u0442\u0441\u044f.<\/p>\n<p>  \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0443\u0434\u0438\u0432\u0438\u0442\u044c\u0441\u044f: \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 <code>PersistencyManager<\/code> \u0432 \u0433\u043b\u0430\u0432\u0435 \u043f\u0440\u043e \u0441\u0438\u043d\u0433\u043b\u0442\u043e\u043d\u044b? \u0421\u0432\u044f\u0437\u044c \u043c\u0435\u0436\u0434\u0443 <code>LibraryAPI<\/code> \u0438 <code>PersistencyManager<\/code> \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u0430 \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0433\u043b\u0430\u0432\u0435.<\/p>\n<h2>\u0424\u0430\u0441\u0430\u0434<\/h2>\n<p>  <img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/642\/c8c\/a40\/642c8ca40d08000990736a2c0182cdfe.png\"\/><\/p>\n<p>  \u041f\u0430\u0442\u0442\u0435\u0440\u043d \u00ab\u0424\u0430\u0441\u0430\u0434\u00bb \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0435\u0434\u0438\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u043a \u0441\u043b\u043e\u0436\u043d\u043e\u0439 \u043f\u043e\u0434\u0441\u0438\u0441\u0442\u0435\u043c\u0435. \u0427\u0442\u043e\u0431\u044b \u043d\u0435 \u0448\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u044e\u0437\u0435\u0440\u043e\u0432 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e\u043c \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0441 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430\u043c\u0438, \u043c\u044b \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u043e\u0434\u0438\u043d \u043f\u0440\u043e\u0441\u0442\u043e\u0439 API:<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/d23\/195\/3e0\/d231953e05d3fed2984e83c20dc0a065.png\"\/><\/p>\n<p>  \u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u044d\u0442\u043e\u0433\u043e API \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u043d\u0435 \u0431\u0435\u0441\u043f\u043e\u043a\u043e\u0438\u0442\u0441\u044f \u043e \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0435\u0439 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u044b. \u042d\u0442\u043e\u0442 \u043f\u0430\u0442\u0442\u0435\u0440\u043d \u0438\u0434\u0435\u0430\u043b\u0435\u043d \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u0431\u043e\u043b\u044c\u0448\u0438\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u043a\u043b\u0430\u0441\u0441\u043e\u0432, \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438.<\/p>\n<p>  \u041f\u0430\u0442\u0442\u0435\u0440\u043d \u00ab\u0424\u0430\u0441\u0430\u0434\u00bb \u043e\u0442\u0434\u0435\u043b\u044f\u0435\u0442 \u043a\u043e\u0434 (API), \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0431\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u043a \u043f\u043e\u0434\u0441\u0438\u0441\u0442\u0435\u043c\u0435, \u043e\u0442 \u0442\u0435\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0441\u043f\u0440\u044f\u0442\u0430\u0442\u044c. \u041e\u043d \u0443\u043c\u0435\u043d\u044c\u0448\u0430\u0435\u0442 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u0432\u043d\u0435\u0448\u043d\u0435\u0433\u043e \u043a\u043e\u0434\u0430 \u043e\u0442 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0435\u0439 \u043a\u0443\u0445\u043d\u0438 \u043f\u043e\u0434\u0441\u0438\u0441\u0442\u0435\u043c\u044b. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u044d\u0442\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u043e, \u043a\u043e\u0433\u0434\u0430 \u043a\u043b\u0430\u0441\u0441\u044b, \u0441\u043a\u0440\u044b\u0442\u044b\u0435 \u0437\u0430 \u0444\u0430\u0441\u0430\u0434\u043e\u043c, \u0441 \u0432\u044b\u0441\u043e\u043a\u043e\u0439 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c\u044e \u043c\u043e\u0433\u0443\u0442 \u043f\u043e\u0434\u0432\u0435\u0440\u0433\u043d\u0443\u0442\u044c\u0441\u044f \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438. \u0424\u0430\u0441\u0430\u0434 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0432\u0441\u0451 \u0442\u043e\u0442 \u0436\u0435 API, \u0432 \u0442\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u0430\u043a \u0432\u0441\u0451 \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u0437\u0430 \u043a\u0443\u043b\u0438\u0441\u0430\u043c\u0438.<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/3a7\/fe9\/72f\/3a7fe972ff3522dc394a3152c197e7a8.jpg\"\/><\/p>\n<p>  <s>\u0415\u0441\u043b\u0438<\/s>\u041a\u043e\u0433\u0434\u0430 \u043f\u0440\u0438\u0434\u0451\u0442 \u0432\u0440\u0435\u043c\u044f \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u0432\u0430\u0448 \u0431\u044d\u043a\u0435\u043d\u0434, \u0432\u0430\u043c \u043d\u0435 \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u043a\u043e\u0434, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0438\u0439 API, \u0442.\u043a. API \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u0441\u044f.<\/p>\n<h3>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0430 \u00ab\u0424\u0430\u0441\u0430\u0434\u00bb<\/h3>\n<p>  \u0421\u0435\u0439\u0447\u0430\u0441 \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c <code>PersistencyManager<\/code> \u0434\u043b\u044f \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 <code>HTTPClient<\/code> \u0434\u043b\u044f \u0441\u0435\u0442\u0435\u0432\u043e\u0433\u043e \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f. \u0414\u0440\u0443\u0433\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u044b \u0432 \u0432\u0430\u0448\u0435\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u0434\u0443\u043c\u0430\u0442\u044c \u043e\u0431 \u044d\u0442\u0438\u0445 \u0434\u0432\u0443\u0445 \u0432\u0435\u0449\u0430\u0445.<\/p>\n<p>  \u0414\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u044d\u0442\u043e\u0433\u043e \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0430, \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u043a\u043b\u0430\u0441\u0441 \u2014 <code>LibraryAPI<\/code> \u2014 \u0434\u043e\u043b\u0436\u0435\u043d \u0441\u0441\u044b\u043b\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u044b <code>PersistencyManager<\/code> \u0438 <code>HTTPClient<\/code>. <code>LibraryAPI<\/code> \u2014 \u044d\u0442\u043e \u0438 \u0435\u0441\u0442\u044c \u0442\u043e\u0442 \u0444\u0430\u0441\u0430\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0434\u043b\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0441\u0435\u0440\u0432\u0438\u0441\u0430\u043c (\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0430 \u0434\u0430\u043d\u043d\u044b\u0445).<\/p>\n<p>  <b>\u0417\u0430\u043c\u0435\u0447\u0430\u043d\u0438\u0435.<\/b> \u041e\u0431\u044b\u0447\u043d\u043e \u043e\u0431\u044a\u0435\u043a\u0442-\u0441\u0438\u043d\u0433\u043b\u0442\u043e\u043d \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0432 \u0442\u0435\u0447\u0435\u043d\u0438\u0435 \u0432\u0441\u0435\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b. \u041d\u0435 \u043d\u0443\u0436\u043d\u043e \u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0432 \u0441\u0438\u043d\u0433\u043b\u0442\u043e\u043d\u0435 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043c\u043d\u043e\u0433\u043e \u00ab\u0441\u0438\u043b\u044c\u043d\u044b\u0445\u00bb \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0435\u0439 \u043d\u0430 \u0434\u0440\u0443\u0433\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b, \u0442.\u043a. \u043e\u043d\u0438 \u043d\u0435 \u0431\u0443\u0434\u0443\u0442 \u043e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0435\u043d\u044b \u0438\u0437 \u043f\u0430\u043c\u044f\u0442\u0438 \u0434\u043e \u0442\u0435\u0445 \u043f\u043e\u0440, \u043f\u043e\u043a\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0435 \u0437\u0430\u043a\u0440\u043e\u0435\u0442\u0441\u044f.  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u0441\u0438\u043b\u044c\u043d\u044b\u0439 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c (strong pointer)?<\/b><\/p>\n<div class=\"spoiler_text\">\u041d\u0430 Stack Overflow \u043d\u0430\u0448\u0451\u043b\u0441\u044f <a href=\"http:\/\/stackoverflow.com\/questions\/9262535\/explanation-of-strong-and-weak-storage-in-ios5\">\u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0439 \u043e\u0442\u0432\u0435\u0442<\/a>:<\/p>\n<p>  \u0421\u0431\u043e\u0440\u0449\u0438\u043a \u043c\u0443\u0441\u043e\u0440\u0430 \u043e\u0441\u0432\u043e\u0431\u043e\u0434\u0438\u0442 \u043f\u0430\u043c\u044f\u0442\u044c \u0438\u0437-\u043f\u043e\u0434 \u043e\u0431\u044a\u0435\u043a\u0442\u0430, \u043a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0435 \u043e\u0441\u0442\u0430\u043d\u0435\u0442\u0441\u044f \u00ab\u0441\u0438\u043b\u044c\u043d\u044b\u0445\u00bb \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0435\u0439 \u043d\u0430 \u043d\u0435\u0433\u043e. \u0414\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u0435\u0441\u0442\u044c \u00ab\u0441\u043b\u0430\u0431\u044b\u0435\u00bb \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0438 (weak pointer) \u2014 \u043a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044f\u044f \u0441\u0438\u043b\u044c\u043d\u0430\u044f \u0441\u0441\u044b\u043b\u043a\u0430 \u0443\u0434\u0430\u043b\u0435\u043d\u0430, \u043e\u0431\u044a\u0435\u043a\u0442 \u043e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0430\u0435\u0442\u0441\u044f \u0438\u0437 \u043f\u0430\u043c\u044f\u0442\u0438, \u0430 \u043e\u0441\u0442\u0430\u0432\u0448\u0438\u0435\u0441\u044f \u00ab\u0441\u043b\u0430\u0431\u044b\u0435\u00bb \u0441\u0441\u044b\u043b\u043a\u0438 \u043e\u0431\u043d\u0443\u043b\u044f\u044e\u0442\u0441\u044f.<\/p>\n<p>  <b>\u041f\u0440\u0438\u043c\u0435\u0440<\/b><br \/>  \u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u044c\u0442\u0435, \u0447\u0442\u043e \u043d\u0430\u0448 \u043e\u0431\u044a\u0435\u043a\u0442 \u2014 \u044d\u0442\u043e \u0441\u043e\u0431\u0430\u043a\u0430. \u0421\u043e\u0431\u0430\u043a\u0430 \u0445\u043e\u0447\u0435\u0442 \u00ab\u0443\u0431\u0435\u0436\u0430\u0442\u044c\u00bb (\u043e\u0441\u0432\u043e\u0431\u043e\u0434\u0438\u0442\u044c \u043f\u0430\u043c\u044f\u0442\u044c).<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/8fc\/861\/e8e\/8fc861e8e56c0a776d5fac3684ae7e5e.jpg\"\/><\/p>\n<p>  \u0421\u0438\u043b\u044c\u043d\u044b\u0439 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u2014 \u044d\u0442\u043e \u043f\u043e\u0432\u043e\u0434\u043e\u043a \u0441 \u043e\u0448\u0435\u0439\u043d\u0438\u043a\u043e\u043c. \u041f\u043e\u043a\u0430 \u043f\u043e\u0432\u043e\u0434\u043e\u043a \u043f\u0440\u0438\u0446\u0435\u043f\u043b\u0435\u043d \u043a \u043e\u0448\u0435\u0439\u043d\u0438\u043a\u0443, \u0441\u043e\u0431\u0430\u043a\u0430 \u043d\u0435 \u0443\u0431\u0435\u0436\u0438\u0442. \u0415\u0441\u043b\u0438 5 \u0447\u0435\u043b\u043e\u0432\u0435\u043a \u043f\u0440\u0438\u0446\u0435\u043f\u044f\u0442 5 \u043f\u043e\u0432\u043e\u0434\u043a\u043e\u0432 \u043a \u043e\u0434\u043d\u043e\u043c\u0443 \u043e\u0448\u0435\u0439\u043d\u0438\u043a\u0443 (5 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0435\u0439 \u043d\u0430 1 \u043e\u0431\u044a\u0435\u043a\u0442) \u2014 \u0441\u043e\u0431\u0430\u043a\u0430 \u043d\u0435 \u0443\u0431\u0435\u0436\u0438\u0442 \u0434\u043e \u0442\u0435\u0445 \u043f\u043e\u0440, \u043f\u043e\u043a\u0430 \u043d\u0435 \u043e\u0442\u0446\u0435\u043f\u044f\u0442 \u0432\u0441\u0435 5 \u043f\u043e\u0432\u043e\u0434\u043a\u043e\u0432.<\/p>\n<p>  \u0410 \u0441\u043b\u0430\u0431\u044b\u0435 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0438 \u2014 \u044d\u0442\u043e \u0434\u0435\u0442\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0442\u044b\u0447\u0443\u0442 \u043f\u0430\u043b\u044c\u0446\u0435\u043c \u043d\u0430 \u0441\u043e\u0431\u0430\u043a\u0443 \u0438 \u043a\u0440\u0438\u0447\u0430\u0442: \u00ab\u0423\u0445 \u0442\u044b, \u0441\u043e\u0431\u0430\u043a\u0430!\u00bb \u041f\u043e\u043a\u0430 \u0441\u043e\u0431\u0430\u043a\u0430 \u043d\u0430 \u043f\u043e\u0432\u043e\u0434\u043a\u0435, \u043e\u043d\u0438 \u043c\u043e\u0433\u0443\u0442 \u0442\u044b\u043a\u0430\u0442\u044c (\u00ab\u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043d\u0430 \u043e\u0431\u044a\u0435\u043a\u0442\u00bb) \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0443\u0433\u043e\u0434\u043d\u043e. \u041d\u043e \u0435\u0441\u043b\u0438 \u043e\u0442\u0441\u043e\u0435\u0434\u0438\u043d\u0438\u0442\u044c \u0432\u0441\u0435 \u043f\u043e\u0432\u043e\u0434\u043a\u0438, \u0442\u043e \u0441\u043e\u0431\u0430\u043a\u0430 \u0443\u0431\u0435\u0436\u0438\u0442, \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e \u043e\u0442 \u0442\u043e\u0433\u043e, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0434\u0435\u0442\u0435\u0439 \u0442\u044b\u0447\u0443\u0442 \u0432 \u043d\u0435\u0451 \u043f\u0430\u043b\u044c\u0446\u0435\u043c.<\/p><\/div>\n<\/div>\n<p>  \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a\u0430\u044f \u0441\u0445\u0435\u043c\u0430:<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/896\/326\/cb3\/896326cb38d71cb0f7c0ed4b1bb9be50.png\"\/><\/p>\n<p>  <code>LibraryAPI<\/code> \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u043a\u0440\u044b\u0442\u0430 \u0432\u043d\u0435\u0448\u043d\u0435\u043c\u0443 \u043a\u043e\u0434\u0443, \u043d\u043e \u0441\u043a\u0440\u043e\u0435\u0442 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043a\u043b\u0430\u0441\u0441\u043e\u0432 <code>HTTPClient<\/code> \u0438 <code>PersistencyManager<\/code> \u043e\u0442 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/p>\n<p>  \u041e\u0442\u043a\u0440\u043e\u0439\u0442\u0435 <b>LibraryAPI.h<\/b> \u0438 \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0432 \u043d\u0430\u0447\u0430\u043b\u043e \u0444\u0430\u0439\u043b\u0430 \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u0443:<\/p>\n<pre><code class=\"cpp\">#import &quot;Album.h&quot; <\/code><\/pre>\n<p>  \u041d\u0438\u0436\u0435 \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0432 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441:<\/p>\n<pre><code class=\"cpp\">- (NSArray *)getAlbums; - (void)addAlbum:(Album *)album atIndex:(int)index; - (void)deleteAlbumAtIndex:(int)index; <\/code><\/pre>\n<p>  \u0412\u043e\u0442 \u0442\u0435 \u043c\u0435\u0442\u043e\u0434\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u043e\u0442\u043a\u0440\u044b\u0442\u044b \u0434\u0440\u0443\u0433\u0438\u043c \u043a\u043b\u0430\u0441\u0441\u0430\u043c.<\/p>\n<p>  \u041f\u0435\u0440\u0435\u0439\u0434\u0438\u0442\u0435 \u043a <b>LibraryAPI.m<\/b> \u0438 \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0432 \u043d\u0430\u0447\u0430\u043b\u043e:<\/p>\n<pre><code class=\"cpp\">#import &quot;PersistencyManager.h&quot; #import &quot;HTTPClient.h&quot; <\/code><\/pre>\n<p>  \u042d\u0442\u043e \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435 \u043c\u0435\u0441\u0442\u043e, \u0433\u0434\u0435 \u043c\u044b \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u044d\u0442\u0438 \u043a\u043b\u0430\u0441\u0441\u044b! \u0412\u0430\u0448 API \u0431\u0443\u0434\u0435\u0442 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u043e\u0439 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0432\u0430\u0448\u0435\u0439 \u00ab\u0441\u043b\u043e\u0436\u043d\u043e\u0439\u00bb \u0441\u0438\u0441\u0442\u0435\u043c\u0435.<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0442\u0440\u0438 \u0437\u0430\u043a\u0440\u044b\u0442\u044b\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0432 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u0430 (\u043d\u0430\u0434 \u0441\u0442\u0440\u043e\u0447\u043a\u043e\u0439 <code>@implementation<\/code>):<\/p>\n<pre><code class=\"cpp\">@interface LibraryAPI () {     PersistencyManager * persistencyManager;     HTTPClient * httpClient;     BOOL isOnline; } @end <\/code><\/pre>\n<p>  \u041f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0430\u0442\u0435\u043b\u044c <code>isOnline<\/code> \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442: \u0434\u043e\u043b\u0436\u043d\u044b \u043b\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u0441 \u0430\u043b\u044c\u0431\u043e\u043c\u0430\u043c\u0438 (\u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435, \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435) \u043f\u043e\u0441\u0442\u0443\u043f\u0430\u0442\u044c \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440?<\/p>\n<p>  \u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u044d\u0442\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435. \u0414\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0432 <b>LibraryAPI.m<\/b>:<\/p>\n<pre><code class=\"cpp\">- (id)init {     self = [super init];     if (self)     {         persistencyManager = [[PersistencyManager alloc] init];         httpClient = [[HTTPClient alloc] init];         isOnline = NO;     }     return self; } <\/code><\/pre>\n<p>  <b>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435:<\/b> HTTP-\u043a\u043b\u0438\u0435\u043d\u0442 \u0443 \u043d\u0430\u0441 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u043c \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u043c. \u041e\u043d \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0437\u0434\u0435\u0441\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0430 \u00ab\u0424\u0430\u0441\u0430\u0434\u00bb. <code>isOnline<\/code> \u0432\u0441\u0435\u0433\u0434\u0430 \u0431\u0443\u0434\u0435\u0442 <code>NO<\/code>.<\/p>\n<p>  \u0417\u0430\u0442\u0435\u043c \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0442\u0440\u0438 \u043c\u0435\u0442\u043e\u0434\u0430 \u0432 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043a\u043b\u0430\u0441\u0441\u0430 <code>LibraryAPI<\/code>:<\/p>\n<pre><code class=\"cpp\">- (NSArray *)getAlbums {     return [persistencyManager getAlbums]; }  - (void)addAlbum:(Album *)album atIndex:(int)index {     [persistencyManager addAlbum:album atIndex:index];     if (isOnline)     {         [httpClient postRequest:@&quot;\/api\/addAlbum&quot; body:[album description]];     } }  - (void)deleteAlbumAtIndex:(int)index {     [persistencyManager deleteAlbumAtIndex:index];     if (isOnline)     {         [httpClient postRequest:@&quot;\/api\/deleteAlbum&quot; body:[@(index) description]];     } } <\/code><\/pre>\n<p>  \u0412\u0437\u0433\u043b\u044f\u043d\u0438\u0442\u0435 \u043d\u0430 \u043c\u0435\u0442\u043e\u0434 <code>addAlbum:atIndex:<\/code>. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043e\u043d \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e, \u0430 \u0437\u0430\u0442\u0435\u043c, \u0435\u0441\u043b\u0438 \u0435\u0441\u0442\u044c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043a \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0443, \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0430 \u0443\u0434\u0430\u043b\u0451\u043d\u043d\u043e\u043c \u0441\u0435\u0440\u0432\u0435\u0440\u0435. \u042d\u0442\u043e \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u043e \u00ab\u0424\u0430\u0441\u0430\u0434\u0430\u00bb: \u043a\u043e\u0433\u0434\u0430 \u043a\u0430\u043a\u043e\u0439-\u043d\u0438\u0431\u0443\u0434\u044c \u043a\u043b\u0430\u0441\u0441 \u0437\u0430 \u043f\u0440\u0435\u0434\u0435\u043b\u0430\u043c\u0438 <s>\u0421\u043e\u043b\u043d\u0435\u0447\u043d\u043e\u0439<\/s> \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u043d\u043e\u0432\u044b\u0439 \u0430\u043b\u044c\u0431\u043e\u043c, \u043e\u043d \u043d\u0435 \u0437\u043d\u0430\u0435\u0442 \u2014 \u0438 \u043d\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u0437\u043d\u0430\u0442\u044c \u2014 \u043e \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0441\u043a\u0440\u044b\u0442\u043e \u0432\u043d\u0443\u0442\u0440\u0438.<\/p>\n<p>  <b>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435:<\/b> \u041f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0430 \u00ab\u0424\u0430\u0441\u0430\u0434\u00bb \u043f\u043e\u043c\u043d\u0438\u0442\u0435, \u0447\u0442\u043e \u043d\u0438\u0447\u0442\u043e \u043d\u0435 \u043c\u0435\u0448\u0430\u0435\u0442 \u043a\u043b\u0438\u0435\u043d\u0442\u0443 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u00ab\u0441\u043a\u0440\u044b\u0442\u044b\u043c\u00bb \u043a\u043b\u0430\u0441\u0441\u0430\u043c \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e. \u041d\u0435 \u044d\u043a\u043e\u043d\u043e\u043c\u044c\u0442\u0435 \u043d\u0430 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0434\u043b\u044f \u00ab\u0437\u0430\u0449\u0438\u0442\u044b \u043e\u0442 \u0434\u0443\u0440\u0430\u043a\u0430\u00bb \u0438\u043b\u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u0438\u043c\u0435\u0439\u0442\u0435 \u0432 \u0432\u0438\u0434\u0443, \u0447\u0442\u043e \u043d\u0435 \u0432\u0441\u0435 \u0431\u0443\u0434\u0443\u0442 \u0438\u0433\u0440\u0430\u0442\u044c \u043f\u043e \u0432\u0430\u0448\u0438\u043c \u043f\u0440\u0430\u0432\u0438\u043b\u0430\u043c.<\/p>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435. \u0418\u0434\u0435\u0430\u043b\u044c\u043d\u043e \u0447\u0435\u0440\u043d\u044b\u0439 \u044d\u043a\u0440\u0430\u043d:<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/543\/082\/11f\/54308211f34b30896af670d3e5ea6c63.png\"\/><\/p>\n<p>  \u041d\u0430 iOS 6 \u043c\u044b \u0431\u044b \u0443\u0432\u0438\u0434\u0435\u043b\u0438 \u0441\u0442\u0430\u0442\u0443\u0441-\u0431\u0430\u0440 \u0441 \u0447\u0430\u0441\u0430\u043c\u0438. \u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 iOS 7 \u043b\u0438\u0448\u0435\u043d\u044b \u0438 \u044d\u0442\u043e\u0433\u043e. \u0422\u0435\u043a\u0441\u0442 \u0438 \u0441\u0438\u043c\u0432\u043e\u043b\u044b \u043f\u043e \u0434\u0435\u0444\u043e\u043b\u0442\u0443 \u0447\u0451\u0440\u043d\u044b\u0435.<\/p>\n<p>  \u041d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0447\u0442\u043e-\u0442\u043e \u0434\u043b\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e\u0431 \u0430\u043b\u044c\u0431\u043e\u043c\u0435. \u041e\u0442\u043b\u0438\u0447\u043d\u044b\u0439 \u043f\u043e\u0432\u043e\u0434 \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043a \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c\u0443 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0443, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f\u2026<\/p>\n<h2>\u0414\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440<\/h2>\n<p>  \u0413\u043e\u0432\u043e\u0440\u044f \u0443\u043c\u043d\u044b\u043c\u0438 \u0441\u043b\u043e\u0432\u0430\u043c\u0438, \u0448\u0430\u0431\u043b\u043e\u043d \u00ab\u0414\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u00bb \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 (behaviors) \u0438 \u043e\u0431\u044f\u0437\u0430\u043d\u043d\u043e\u0441\u0442\u0438 (responsibilities) \u043a \u043e\u0431\u044a\u0435\u043a\u0442\u0443, \u043d\u0435 \u043c\u0435\u043d\u044f\u044f \u0435\u0433\u043e \u043a\u043e\u0434. \u042d\u0442\u043e \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u0430 \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044e (\u043f\u0440\u0438 \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0438 \u0432\u044b \u043c\u0435\u043d\u044f\u0435\u0442\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u0430, \u043e\u0431\u0435\u0440\u043d\u0443\u0432 \u0435\u0433\u043e \u0432 \u043f\u043e\u0434\u043a\u043b\u0430\u0441\u0441).<\/p>\n<p>  \u0412 Objective-C \u0435\u0441\u0442\u044c \u0434\u0432\u0435 <i>\u043e\u0447\u0435\u043d\u044c<\/i> \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u043d\u044b\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u044d\u0442\u043e\u0433\u043e \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0430: \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0438 \u0438 \u0434\u0435\u043b\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435.<\/p>\n<h3>\u041a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0438<\/h3>\n<p>  \u00ab\u041a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u044f\u00bb (Category) \u2014 \u043e\u0447\u0435\u043d\u044c \u043c\u043e\u0449\u043d\u044b\u0439 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0439 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u044b \u043a \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u043c \u043a\u043b\u0430\u0441\u0441\u0430\u043c \u0431\u0435\u0437 \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f. \u041d\u043e\u0432\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043f\u0440\u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u0438 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u044b \u043a\u0430\u043a \u043e\u0431\u044b\u0447\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430. \u042d\u0442\u043e \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f \u043e\u0442 \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u00ab\u0414\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u0430\u00bb, \u0442.\u043a. \u00ab\u041a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u044f\u00bb \u043d\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043a\u043b\u0430\u0441\u0441\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u043d\u0430 \u0440\u0430\u0441\u0448\u0438\u0440\u044f\u0435\u0442.<\/p>\n<p>  <b>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435:<\/b> \u041a\u0440\u043e\u043c\u0435 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432, \u0432\u044b \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u0435\u0442\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u044b \u043a \u043b\u044e\u0431\u044b\u043c \u043a\u043b\u0430\u0441\u0441\u0430\u043c Cocoa!<\/p>\n<h4>\u041a\u0430\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0438<\/h4>\n<p>  \u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u044c\u0442\u0435 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044e: \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442 <code>Album<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435:<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/79b\/7d9\/8ab\/79b7d98ab7da196a3a353315a1762409.png\"\/><\/p>\n<p>  \u041e\u0442\u043a\u0443\u0434\u0430 \u043a \u043d\u0430\u043c \u043f\u0440\u0438\u0434\u0451\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e\u0431 \u0430\u043b\u044c\u0431\u043e\u043c\u0435? <code>Album<\/code> \u2014 \u044d\u0442\u043e \u043e\u0431\u044a\u0435\u043a\u0442 \u00ab\u043c\u043e\u0434\u0435\u043b\u044c\u00bb, \u0435\u043c\u0443 \u0431\u0435\u0437 \u0440\u0430\u0437\u043d\u0438\u0446\u044b, \u0432 \u043a\u0430\u043a\u043e\u043c \u0432\u0438\u0434\u0435 \u043c\u044b \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435. \u041d\u0430\u043c \u043d\u0443\u0436\u0435\u043d \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u043d\u0435\u0448\u043d\u0438\u0439 (\u043f\u043e \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044e \u043a <code>Album<\/code>) \u043a\u043e\u0434, \u0447\u0442\u043e\u0431\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b \u043a \u043a\u043b\u0430\u0441\u0441\u0443 <code>Album<\/code>, \u043d\u0435 \u0442\u0440\u043e\u0433\u0430\u044f \u043a\u043e\u0434 <code>Album<\/code>.<\/p>\n<p>  \u041c\u044b \u0441 \u0432\u0430\u043c\u0438 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u044e \u2014 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u0430 <code>Album<\/code>. \u041c\u0435\u0442\u043e\u0434\u044b \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0438 \u0431\u0443\u0434\u0443\u0442 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0434\u0430\u043d\u043d\u044b\u0445, \u0443\u0434\u043e\u0431\u043d\u0443\u044e \u0434\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0432 <code>UITableView<\/code>.<\/p>\n<p>  \u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a:<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/43f\/dbe\/87c\/43fdbe87cdefbf1af55a9c0667a25347.png\"\/><\/p>\n<p>  \u0427\u0442\u043e\u0431\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u044e \u043a \u043a\u043b\u0430\u0441\u0441\u0443 <b>Album<\/b>, \u0441\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u043d\u043e\u0432\u044b\u0439 \u0444\u0430\u0439\u043b \u043f\u043e \u0448\u0430\u0431\u043b\u043e\u043d\u0443 <b>Objective-C category<\/b> (\u043d\u0435 \u0432\u044b\u0431\u0435\u0440\u0438\u0442\u0435 \u043f\u043e \u043f\u0440\u0438\u0432\u044b\u0447\u043a\u0435 Objective-C class!)<br \/>  \u0417\u0430\u043f\u043e\u043b\u043d\u0438\u0442\u0435 \u043f\u043e\u043b\u044f:<br \/>  <b>Category<\/b>: <code>TableRepresentation<\/code><br \/>  <b>Category on<\/b>: <code>Album<\/code><\/p>\n<p>  \u0417\u0430\u043c\u0435\u0442\u0438\u043b\u0438 \u043d\u043e\u0432\u043e\u0435 \u0438\u043c\u044f \u0444\u0430\u0439\u043b\u0430? <code>Album+TableRepresentation<\/code> \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u043c\u044b \u0440\u0430\u0441\u0448\u0438\u0440\u044f\u0435\u043c \u043a\u043b\u0430\u0441\u0441 <code>Album<\/code>. \u0412\u0430\u0436\u043d\u043e \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e\u043c\u0443 \u0441\u043e\u0433\u043b\u0430\u0448\u0435\u043d\u0438\u044e, \u0442\u0430\u043a \u043a\u0430\u043a \u043e\u043d\u043e \u043e\u0431\u043b\u0435\u0433\u0447\u0430\u0435\u0442 \u0447\u0442\u0435\u043d\u0438\u0435 \u0438 \u043f\u0440\u0435\u0434\u043e\u0442\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0435 \u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u044f \u0441 \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u044f\u043c\u0438 (\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0432\u044b \u0438\u043b\u0438 \u043a\u0442\u043e-\u0442\u043e \u0435\u0449\u0451).<\/p>\n<p>  \u041f\u0435\u0440\u0435\u0439\u0434\u0438\u0442\u0435 \u043a <b>Album+TableRepresentation.h<\/b> \u0438 \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f \u043c\u0435\u0442\u043e\u0434\u0430:<\/p>\n<pre><code class=\"cpp\">- (NSDictionary *)tr_tableRepresentation; <\/code><\/pre>\n<p>  \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u043f\u0440\u0435\u0444\u0438\u043a\u0441 \u0438\u043c\u0435\u043d\u0438 \u043c\u0435\u0442\u043e\u0434\u0430: <code>tr_<\/code> \u2014 \u0430\u0431\u0431\u0440\u0435\u0432\u0438\u0430\u0442\u0443\u0440\u0430 \u043e\u0442 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0438 (<code>TableRepresentation<\/code>). \u042d\u0442\u043e \u0435\u0449\u0451 \u043e\u0434\u043d\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u043e, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u043d\u0430\u043c \u043f\u0440\u0435\u0434\u043e\u0442\u0432\u0440\u0430\u0442\u0438\u0442\u044c \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u044f \u0441 \u0438\u043c\u0435\u043d\u0430\u043c\u0438 \u0434\u0440\u0443\u0433\u0438\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432.<\/p>\n<p>  <b>\u0412\u0430\u0436\u043d\u043e\u0435 \u0437\u0430\u043c\u0435\u0447\u0430\u043d\u0438\u0435.<\/b> \u0415\u0441\u043b\u0438 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u0430, \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0432 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0438, \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u0435\u0442 \u0441 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c \u043c\u0435\u0442\u043e\u0434\u0430 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 (\u0438\u043b\u0438 \u0441 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c \u043c\u0435\u0442\u043e\u0434\u0430 \u0434\u0440\u0443\u0433\u043e\u0439 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0438 \u044d\u0442\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u0438\u043b\u0438 \u0434\u0430\u0436\u0435 \u0435\u0433\u043e \u0441\u0443\u043f\u0435\u0440\u043a\u043b\u0430\u0441\u0441\u0430) \u2014 \u0432 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 <i>\u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043d\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043e<\/i>. \u0412\u043e\u0442 \u0442\u0430\u043a. \u041d\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e, \u043a\u0430\u043a\u043e\u0439 \u0438\u0437 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d. \u042d\u0442\u043e \u043d\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430, \u0435\u0441\u043b\u0438 \u0432\u044b \u043e\u043f\u0435\u0440\u0438\u0440\u0443\u0435\u0442\u0435 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u044f\u043c\u0438 \u043d\u0430\u0434 \u0441\u0432\u043e\u0438\u043c\u0438 \u043a\u043b\u0430\u0441\u0441\u0430\u043c\u0438. \u041d\u043e \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0438\u0435 \u0442\u0440\u0443\u0434\u043d\u043e\u0441\u0442\u0438, \u0435\u0441\u043b\u0438 \u0432\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0438 \u0434\u043b\u044f \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 <b>Cocoa<\/b> \u0438\u043b\u0438 <b>Cocoa Touch<\/b>.<\/p>\n<p>  \u041f\u0435\u0440\u0435\u0439\u0434\u0438\u0442\u0435 \u0432 <b>Album+TableRepresentation.m<\/b> \u0438 \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043c\u0435\u0442\u043e\u0434:<\/p>\n<pre><code class=\"cpp\">- (NSDictionary *)tr_tableRepresentation {     return @{@&quot;titles&quot;:@[@&quot;\u0418\u0441\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c&quot;, @&quot;\u0410\u043b\u044c\u0431\u043e\u043c&quot;, @&quot;\u0416\u0430\u043d\u0440&quot;, @&quot;\u0413\u043e\u0434&quot;],              @&quot;values&quot;:@[self.artist, self.title, self.genre, self.year]}; } <\/code><\/pre>\n<p>  \u0422\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0434\u0443\u043c\u0430\u0439\u0442\u0435, \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u043e\u0449\u043d\u044b\u0439 \u043f\u0430\u0442\u0442\u0435\u0440\u043d:  <\/p>\n<ul>\n<li>\u041c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u043f\u0440\u044f\u043c\u043e \u0438\u0437 <code>Album<\/code>.<\/li>\n<li>\u041c\u044b \u0440\u0430\u0441\u0448\u0438\u0440\u0438\u043b\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b \u043a\u043b\u0430\u0441\u0441\u0430 <code>Album<\/code> \u0431\u0435\u0437 \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f. (\u0415\u0441\u043b\u0438 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c \u043e\u0442 Album, \u044d\u0442\u043e \u0442\u043e\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c.)<\/li>\n<li>\u042d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e\u0435 \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043d\u0430\u043c <code>UITableView<\/code>&#8216;\u0448\u043d\u043e\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 <code>Album<\/code>&#8216;\u0430 \u0431\u0435\u0437 \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0441\u0430\u043c\u043e\u0433\u043e \u043a\u043e\u0434\u0430 <code>Album<\/code>.  <\/li>\n<\/ul>\n<p>  Apple \u043c\u043d\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0438 \u0432 \u043a\u043b\u0430\u0441\u0441\u0430\u0445 Foundation. \u0427\u0442\u043e\u0431\u044b \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c, \u043a\u0430\u043a \u043e\u043d\u0438 \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u044e\u0442, \u043c\u043e\u0436\u0435\u0442\u0435 \u043e\u0442\u043a\u0440\u044b\u0442\u044c <b>NSString.h<\/b>. \u041d\u0430\u0439\u0434\u0438\u0442\u0435 <code>@interface NSString<\/code> \u2014 \u0442\u0430\u043c \u0432\u044b \u0443\u0432\u0438\u0434\u0438\u0442\u0435 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u0430 \u0441 \u0442\u0440\u0435\u043c\u044f \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u044f\u043c\u0438: <code>NSStringExtensionMethods<\/code>, <code>NSExtendedStringPropertyListParsing<\/code>, <code>NSStringDeprecated<\/code>. \u041a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u0443\u043f\u043e\u0440\u044f\u0434\u043e\u0447\u0438\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u044b, \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u0445 \u043f\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0430\u043c.<\/p>\n<h3>\u0414\u0435\u043b\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435<\/h3>\n<p>  \u0414\u0440\u0443\u0433\u043e\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0430 \u00ab\u0414\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u00bb \u2014 \u044d\u0442\u043e \u0434\u0435\u043b\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435. \u041c\u0435\u0445\u0430\u043d\u0438\u0437\u043c, \u043f\u0440\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043e\u0434\u0438\u043d \u043e\u0431\u044a\u0435\u043a\u0442 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0443\u0435\u0442 \u043e\u0442 \u0438\u043c\u0435\u043d\u0438 \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 (\u0438\u043b\u0438 \u0432 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0446\u0438\u0438 \u0441 \u043d\u0438\u043c). \u041e\u0447\u0435\u043d\u044c \u043f\u043e\u0445\u043e\u0436\u0435 \u043d\u0430 \u0442\u043e, \u043a\u0430\u043a \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c \u0434\u0435\u043b\u0435\u0433\u0438\u0440\u0443\u0435\u0442 \u043f\u043e\u043b\u043d\u043e\u043c\u043e\u0447\u0438\u044f \u043f\u043e\u0434\u0447\u0438\u043d\u0451\u043d\u043d\u044b\u043c.<\/p>\n<p>  \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u0440\u0438\u043c\u0435\u0440: \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 <code>UITableView<\/code> \u043e\u0434\u0438\u043d \u0438\u0437 \u043c\u0435\u0442\u043e\u0434\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c, \u044d\u0442\u043e <code>tableView:numberOfRowsInSection:<\/code> (\u0447\u0438\u0441\u043b\u043e \u0441\u0442\u0440\u043e\u043a \u0432 \u0440\u0430\u0437\u0434\u0435\u043b\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b).<\/p>\n<p>  \u041c\u044b \u043d\u0435 \u043e\u0436\u0438\u0434\u0430\u0435\u043c, \u0447\u0442\u043e <code>UITableView<\/code> \u0441\u0430\u043c \u0437\u043d\u0430\u0435\u0442, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u0440\u043e\u043a \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0432 \u043a\u0430\u0436\u0434\u043e\u043c \u0440\u0430\u0437\u0434\u0435\u043b\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b. \u041f\u043e\u043d\u044f\u0442\u043d\u043e, \u0447\u0442\u043e \u044d\u0442\u043e \u0447\u0438\u0441\u043b\u043e \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 <code>UITableView<\/code> \u043f\u0435\u0440\u0435\u0434\u0430\u0451\u0442 \u0437\u0430\u0434\u0430\u0447\u0443 \u00ab\u0443\u0437\u043d\u0430\u0442\u044c \u0447\u0438\u0441\u043b\u043e \u0441\u0442\u0440\u043e\u043a \u0432 \u043a\u0430\u0436\u0434\u043e\u043c \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u00bb \u0441\u0432\u043e\u0435\u043c\u0443 \u0434\u0435\u043b\u0435\u0433\u0430\u0442\u0443. \u042d\u0442\u043e \u0434\u0430\u0451\u0442 \u0432\u0430\u0436\u043d\u0443\u044e \u0432\u0435\u0449\u044c: \u0441\u0430\u043c \u043a\u043b\u0430\u0441\u0441 <code>UITableView&lt;code&gt; \u043d\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u043c\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445.  \u0412\u043e\u0442 \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442, \u043a\u043e\u0433\u0434\u0430 \u0432\u044b \u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0435 \u043d\u043e\u0432\u044b\u0439 &lt;code&gt;UITableView<\/code>:<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/9c1\/80e\/8b4\/9c180e8b44eae68ba5a9a511cfe853ca.png\"\/><\/p>\n<p>  \u041e\u0431\u044a\u0435\u043a\u0442 <code>UITableView<\/code> \u0434\u0435\u043b\u0430\u0435\u0442 \u0441\u0432\u043e\u044e \u0440\u0430\u0431\u043e\u0442\u0443, \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0443. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0435\u043c\u0443 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0443 \u043d\u0435\u0433\u043e \u043d\u0435\u0442. \u041e\u043d \u043e\u0431\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u043a \u0441\u0432\u043e\u0435\u043c\u0443 \u0434\u0435\u043b\u0435\u0433\u0430\u0442\u0443 (\u0438\u043b\u0438 \u0434\u0435\u043b\u0435\u0433\u0430\u0442\u0430\u043c), \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\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. \u041a\u0441\u0442\u0430\u0442\u0438, \u043a\u043b\u0430\u0441\u0441 \u043c\u043e\u0436\u0435\u0442 \u043e\u0431\u044a\u044f\u0432\u0438\u0442\u044c \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0438 \u043d\u0435\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b (\u043c\u044b \u0443\u0437\u043d\u0430\u0435\u043c \u043e \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430\u0445 \u043f\u043e\u0437\u0436\u0435 \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0443\u0440\u043e\u043a\u0435).<\/p>\n<p>  \u041a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u0431\u044b, \u043f\u0440\u043e\u0449\u0435 \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043e\u0442 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0438 \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b? \u041d\u043e \u0435\u0441\u0442\u044c \u043e\u0434\u0438\u043d \u043c\u043e\u043c\u0435\u043d\u0442: \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0442 \u043e\u0434\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430. \u042f\u0437\u044b\u043a Objective C \u043d\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435 \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435. \u0415\u0441\u043b\u0438 \u0432\u044b \u0437\u0430\u0445\u043e\u0442\u0438\u0442\u0435 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442 \u0434\u0435\u043b\u0435\u0433\u0430\u0442\u043e\u043c \u0434\u0432\u0443\u0445 (\u0438\u043b\u0438 \u0431\u043e\u043b\u0435\u0435) \u0434\u0440\u0443\u0433\u0438\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432, \u0442\u043e \u044d\u0442\u043e\u0433\u043e \u043d\u0435\u043b\u044c\u0437\u044f \u0434\u043e\u0441\u0442\u0438\u0447\u044c \u043f\u0443\u0442\u0451\u043c \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f.<\/p>\n<p>  <b>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435:<\/b> \u044d\u0442\u043e \u0432\u0430\u0436\u043d\u044b\u0439 \u043f\u0430\u0442\u0442\u0435\u0440\u043d. Apple \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u044d\u0442\u043e\u0442 \u043f\u043e\u0434\u0445\u043e\u0434 \u0432 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0435 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 UIKit: <code>UITableView<\/code>, <code>UITextView<\/code>, <code>UITextField<\/code>, <code>UIWebView<\/code>, <code>UIAlert<\/code>, <code>UIActionSheet<\/code>, <code>UICollectionView<\/code>, <code>UIPickerView<\/code>, <code>UIGestureRecognizer<\/code>, <code>UIScrollView<\/code>, \u2026 \u043e\u043a\u0435\u0439, \u043d\u0435 \u0431\u0443\u0434\u0443 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0442\u044c.<\/p>\n<h4>\u041a\u0430\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u0435\u043b\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435<\/h4>\n<p>  \u041e\u0442\u043a\u0440\u043e\u0439\u0442\u0435 <b>ViewController.m<\/b> \u0438 \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0432 \u043d\u0430\u0447\u0430\u043b\u043e \u0444\u0430\u0439\u043b\u0430 \u0435\u0449\u0451 \u043f\u0430\u0440\u0443 \u00ab\u0438\u043c\u043f\u043e\u0440\u0442\u043e\u0432\u00bb:<\/p>\n<pre><code class=\"cpp\">#import &quot;LibraryAPI.h&quot; #import &quot;Album+TableRepresentation.h&quot; <\/code><\/pre>\n<p>  \u0414\u043e\u0431\u0430\u0432\u0438\u043c \u0447\u0435\u0442\u044b\u0440\u0435 \u0447\u0430\u0441\u0442\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0432 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u0430, \u043c\u0435\u0436\u0434\u0443 <code>@interface<\/code> \u0438 <code>@end<\/code>:<\/p>\n<pre><code class=\"cpp\">@interface ViewController () {     UITableView * dataTable;     NSArray * allAlbums;     NSDictionary * currentAlbumData;     int currentAlbumIndex; } @end <\/code><\/pre>\n<p>  \u0418 \u0437\u0434\u0435\u0441\u044c \u0436\u0435 \u2014 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u043a\u043b\u0430\u0441\u0441 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0434\u0435\u043b\u0435\u0433\u0430\u0442\u043e\u043c. \u0414\u043e\u0431\u0430\u0432\u0438\u043c \u0432 \u0443\u0433\u043b\u043e\u0432\u044b\u0445 \u0441\u043a\u043e\u0431\u043a\u0430\u0445 \u043f\u0430\u0440\u0443 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0439:<\/p>\n<pre><code class=\"cpp\">@interface ViewController () &lt;UITableViewDataSource, UITableViewDelegate&gt; <\/code><\/pre>\n<p>  <code>UITableViewDataSource<\/code>, <code>UITableViewDelegate<\/code> \u2014 \u044d\u0442\u043e \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u043e\u0432. \u0422\u0435\u043c \u0441\u0430\u043c\u044b\u043c \u043c\u044b \u0443\u0442\u0432\u0435\u0440\u0436\u0434\u0430\u0435\u043c, \u0447\u0442\u043e \u0434\u0435\u043b\u0435\u0433\u0430\u0442 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u0438\u043c \u0434\u0432\u0443\u043c \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430\u043c. \u042d\u0442\u043e \u0441\u0432\u043e\u0435\u0433\u043e \u0440\u043e\u0434\u0430 \u00ab\u043e\u0431\u0435\u0449\u0430\u043d\u0438\u0435\u00bb \u0434\u0435\u043b\u0435\u0433\u0430\u0442\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430.<\/p>\n<p>  \u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435, <code>UITableView<\/code> \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u043e \u0443\u0432\u0435\u0440\u0435\u043d, \u0447\u0442\u043e \u0434\u0435\u043b\u0435\u0433\u0430\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u0442\u0440\u0435\u0431\u0443\u0435\u043c\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b.<\/p>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u0435 \u043c\u0435\u0442\u043e\u0434 <code>viewDidLoad<\/code> \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434:<\/p>\n<pre><code class=\"cpp\">- (void)viewDidLoad {     [super viewDidLoad];     \/\/ 1     self.view.backgroundColor = [UIColor colorWithRed:0.76f green:0.81f blue:0.87f alpha:1.f];     currentAlbumIndex = 0;      \/\/ 2     allAlbums = [[LibraryAPI sharedInstance] getAlbums];      \/\/ 3     \/\/ UITableView, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u0430\u043b\u044c\u0431\u043e\u043c\u0430     CGRect frame = CGRectMake(0.f, 120.f, self.view.frame.size.width, self.view.frame.size.height - 120.f);     dataTable = [[UITableView alloc] initWithFrame:frame                                              style:UITableViewStyleGrouped];     dataTable.delegate = self;     dataTable.dataSource = self;     dataTable.backgroundView = nil;     [self.view addSubview:dataTable]; } <\/code><\/pre>\n<p>  \u0412\u043e\u0442 \u0430\u043d\u0430\u043b\u0438\u0437 \u044d\u0442\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430:  <\/p>\n<ol>\n<li>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0446\u0432\u0435\u0442 \u0444\u043e\u043d\u0430 \u0432 \u0442\u0451\u043c\u043d\u043e-\u0441\u0438\u043d\u0438\u0439.<\/li>\n<li>\u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0432\u0441\u0435\u0445 \u0430\u043b\u044c\u0431\u043e\u043c\u043e\u0432 \u0447\u0435\u0440\u0435\u0437 API. \u041d\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>PersistencyManager<\/code> \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e!<\/li>\n<li>\u0421\u043e\u0437\u0434\u0430\u0442\u044c <code>UITableView<\/code>. \u041c\u044b \u0437\u0430\u044f\u0432\u043b\u044f\u0435\u043c, \u0447\u0442\u043e \u043d\u0430\u0448 <code>ViewController<\/code> \u2014 \u0434\u0435\u043b\u0435\u0433\u0430\u0442 \u0438 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a \u0434\u0430\u043d\u043d\u044b\u0445 (data source) \u0434\u043b\u044f <code>UITableView<\/code>, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u0441\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043d\u0443\u0436\u043d\u0430 <code>UITableView<\/code>, \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0430 <code>ViewController<\/code>&#8216;\u043e\u043c.<\/li>\n<\/ol>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0435\u0449\u0451 \u043e\u0434\u0438\u043d \u043c\u0435\u0442\u043e\u0434 \u0432 <b>ViewController.m<\/b>:<\/p>\n<pre><code class=\"cpp\">- (void)showDataForAlbumAtIndex:(int)albumIndex {     \/\/ \u0417\u0430\u0449\u0438\u0442\u0430 \u043e\u0442 \u0434\u0443\u0440\u0430\u043a\u0430: \u0443\u0431\u0435\u0434\u0438\u043c\u0441\u044f, \u0447\u0442\u043e \u0437\u0430\u043f\u0440\u043e\u0448\u0435\u043d\u043d\u044b\u0439 \u0438\u043d\u0434\u0435\u043a\u0441 \u043c\u0435\u043d\u044c\u0448\u0435 \u0447\u0438\u0441\u043b\u0430 \u0430\u043b\u044c\u0431\u043e\u043c\u043e\u0432     if (albumIndex &lt; allAlbums.count)     {         \/\/ \u0411\u0435\u0440\u0451\u043c \u0430\u043b\u044c\u0431\u043e\u043c:         Album * album = allAlbums[albumIndex];         \/\/ \u0421\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u0430\u043b\u044c\u0431\u043e\u043c\u0430, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0437\u0436\u0435 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0432 TableView:         currentAlbumData = [album tr_tableRepresentation];     }     else     {         currentAlbumData = nil;     }      \/\/ \u0423 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u044b. \u041e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c TableView     [dataTable reloadData]; } <\/code><\/pre>\n<p>  <code>showDataForAlbumAtIndex:<\/code> \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442 \u043d\u0443\u0436\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e \u0430\u043b\u044c\u0431\u043e\u043c\u0443 \u0438\u0437 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0430\u043b\u044c\u0431\u043e\u043c\u043e\u0432. \u0415\u0441\u043b\u0438 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u043e\u0442\u043e\u0431\u0440\u0430\u0437\u0438\u0442\u044c \u043d\u043e\u0432\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0435 <code>reloadData<\/code>. \u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u044d\u0442\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430, <code>UITableView<\/code> \u0437\u0430\u043d\u043e\u0432\u043e \u043d\u0430\u0447\u043d\u0451\u0442 \u0441\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0442\u044c \u0441\u0432\u043e\u0435\u0433\u043e \u0434\u0435\u043b\u0435\u0433\u0430\u0442\u0430 \u043e \u0442\u0430\u043a\u0438\u0445 \u0432\u0435\u0449\u0430\u0445, \u043a\u0430\u043a, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u043e\u0432 \u0431\u0443\u0434\u0435\u0442 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u0440\u043e\u043a \u0432 \u043a\u0430\u0436\u0434\u043e\u0439 \u0441\u0435\u043a\u0446\u0438\u0438, \u043a\u0430\u043a \u0434\u043e\u043b\u0436\u043d\u0430 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430 \u0438\u043b\u0438 \u0438\u043d\u0430\u044f \u044f\u0447\u0435\u0439\u043a\u0430.<\/p>\n<p>  \u0414\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0441\u0442\u0440\u043e\u043a\u0443 \u0432 \u043a\u043e\u043d\u0435\u0446 <code>viewDidLoad<\/code>:<\/p>\n<pre><code class=\"cpp\">[self showDataForAlbumAtIndex:currentAlbumIndex]; <\/code><\/pre>\n<p>  \u042d\u0442\u0430 \u0441\u0442\u0440\u043e\u0447\u043a\u0430 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u0442 \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u0430\u043b\u044c\u0431\u043e\u043c \u043f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u0422\u0430\u043a \u043a\u0430\u043a \u0438\u043d\u0434\u0435\u043a\u0441 \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u0430\u043b\u044c\u0431\u043e\u043c\u0430 <code>currentAlbumIndex<\/code> \u0431\u044b\u043b \u0440\u0430\u043d\u0435\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d \u0432 <code>0<\/code>, \u043c\u044b \u0432\u0438\u0434\u0438\u043c <s>\u043f\u0435\u0440\u0432\u044b\u0439<\/s> \u043d\u0443\u043b\u0435\u0432\u043e\u0439 \u0430\u043b\u044c\u0431\u043e\u043c \u0432 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438.<\/p>\n<p>  \u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0430 \u0441\u0438\u043c\u0443\u043b\u044f\u0442\u043e\u0440\u0435, \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c\u2026 \u043a\u0440\u044d\u0448:<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage3\/e16\/4ba\/01b\/e164ba01b5c47208352f9da7edd21dc2.png\"\/><\/p>\n<p>  \u0427\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442? \u041c\u044b \u043e\u0431\u044a\u044f\u0432\u0438\u043b\u0438 \u043d\u0430\u0448 <code>ViewController<\/code> \u0434\u0435\u043b\u0435\u0433\u0430\u0442\u043e\u043c \u0438 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u043c \u0434\u0430\u043d\u043d\u044b\u0445 <code>UITableView<\/code>. \u041d\u043e! \u0421\u0434\u0435\u043b\u0430\u0432 \u044d\u0442\u043e, \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u043c\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b (\u0432\u043a\u043b\u044e\u0447\u0430\u044f <code>tableView:numberOfRowsInSection:<\/code>), \u0430 \u043c\u044b \u044d\u0442\u043e\u0433\u043e \u0435\u0449\u0451 \u043d\u0435 \u0441\u0434\u0435\u043b\u0430\u043b\u0438.<\/p>\n<p>  \u0414\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u044d\u0442\u0438 \u0434\u0432\u0430 \u043c\u0435\u0442\u043e\u0434\u0430 \u0432 <b>ViewController.m<\/b>, \u0432 \u043b\u044e\u0431\u043e\u0435 \u043c\u0435\u0441\u0442\u043e \u043c\u0435\u0436\u0434\u0443 <code>@implementation<\/code> \u0438 <code>@end<\/code>:<\/p>\n<pre><code class=\"cpp\">- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {     return [currentAlbumData[@&quot;titles&quot;] count]; }  - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {     UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@&quot;cell&quot;];     if (!cell)     {         cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1                                       reuseIdentifier:@&quot;cell&quot;];     }      cell.textLabel.text = currentAlbumData[@&quot;titles&quot;][indexPath.row];     cell.detailTextLabel.text = currentAlbumData[@&quot;values&quot;][indexPath.row];      return cell; } <\/code><\/pre>\n<p>  <code>tableView:numberOfRowsInSection:<\/code> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0447\u0438\u0441\u043b\u043e \u0441\u0442\u0440\u043e\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0443\u0436\u043d\u043e \u043e\u0442\u043e\u0431\u0440\u0430\u0437\u0438\u0442\u044c \u0432 <code>TableView<\/code>, \u0447\u0442\u043e \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0447\u0438\u0441\u043b\u0443 \u043f\u043e\u043b\u0435\u0439 \u0432 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>  <code>tableView:cellForRowAtIndexPath:<\/code> \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u044f\u0447\u0435\u0439\u043a\u0443 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0441 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c \u043f\u043e\u043b\u044f (<code>title<\/code>) \u0438 \u0435\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c (<code>value<\/code>).<\/p>\n<p>  \u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0432\u043e\u0442 \u0447\u0442\u043e \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0443\u0432\u0438\u0434\u0435\u0442\u044c:<\/p>\n<pre><code class=\"cpp\">&lt;img src=&quot;http:\/\/habrastorage.org\/storage3\/e49\/b63\/195\/e49b63195c791ec8462f65a022278c8a.png&quot;\/&gt; <\/code><\/pre>\n<p>  \u041f\u043e\u043a\u0430 \u0432\u0441\u0451 \u0438\u0434\u0451\u0442 \u043d\u0435\u043f\u043b\u043e\u0445\u043e. \u041d\u043e \u0435\u0441\u043b\u0438 \u0432\u044b \u0432\u0441\u043f\u043e\u043c\u043d\u0438\u0442\u0435 \u043f\u0435\u0440\u0432\u043e\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0432 \u0441\u0442\u0430\u0442\u044c\u0435, \u0442\u0430\u043c \u0431\u044b\u043b \u0438\u043d\u0442\u0440\u0435\u0435\u0441\u043d\u044b\u0439 \u0433\u043e\u0440\u0438\u0437\u043e\u043d\u0442\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u043a\u0440\u043e\u043b\u043b \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043c\u0435\u0436\u0434\u0443 \u0430\u043b\u044c\u0431\u043e\u043c\u0430\u043c\u0438.<\/p>\n<p>  \u0425\u043e\u0447\u0435\u0442\u0441\u044f \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0435 \u00ab\u043e\u0434\u043d\u043e\u0440\u0430\u0437\u043e\u0432\u044b\u0439\u00bb \u0441\u043a\u0440\u043e\u043b\u043b, \u0430 \u0442\u0430\u043a\u043e\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0442\u043e\u043c \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0430 \u043b\u044e\u0431\u043e\u043c \u044d\u043a\u0440\u0430\u043d\u0435, \u0434\u0430? \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432\u0441\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0435\u0433\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0433\u043e \u0434\u043e\u043b\u0436\u043d\u044b \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c\u0441\u044f \u0434\u0440\u0443\u0433\u0438\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u043c \u2014 \u0434\u0435\u043b\u0435\u0433\u0430\u0442\u043e\u043c. \u0413\u043e\u0440\u0438\u0437\u043e\u043d\u0442\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u043a\u0440\u043e\u043b\u043b \u043e\u0431\u044a\u044f\u0432\u0438\u0442 \u043c\u0435\u0442\u043e\u0434\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u0435\u043b\u0435\u0433\u0430\u0442 \u0434\u043e\u043b\u0436\u0435\u043d \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c. \u041f\u043e \u0442\u0438\u043f\u0443 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0438 \u043c\u0435\u0442\u043e\u0434\u044b \u0434\u0435\u043b\u0435\u0433\u0430\u0442\u0430 <code>UITableView<\/code>. \u041c\u044b \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u043e\u0431\u0441\u0443\u0436\u0434\u0435\u043d\u0438\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0430.<\/p>\n<h2>\u00ab\u0410\u0434\u0430\u043f\u0442\u0435\u0440\u00bb<\/h2>\n<p>  \u0410\u0434\u0430\u043f\u0442\u0435\u0440 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043a\u043b\u0430\u0441\u0441\u0430\u043c \u0441 \u043d\u0435\u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u044b\u043c\u0438 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430\u043c\u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0432\u043c\u0435\u0441\u0442\u0435. \u0410\u0434\u0430\u043f\u0442\u0435\u0440 \u2014 \u044d\u0442\u043e \u043e\u0431\u0451\u0440\u0442\u043a\u0430 \u0432\u043e\u043a\u0440\u0443\u0433 \u043e\u0431\u044a\u0435\u043a\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 <i>\u0443\u043d\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439<\/i> \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0434\u043b\u044f \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441 \u044d\u0442\u0438\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u043c.<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage3\/80d\/4e2\/116\/80d4e21169d016fc65d39f9ecda00293.png\"\/><\/p>\n<p>  \u0415\u0441\u043b\u0438 \u0432\u044b \u0437\u043d\u0430\u043a\u043e\u043c\u044b \u0441 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u043e\u043c \u00ab\u0410\u0434\u0430\u043f\u0442\u0435\u0440\u00bb \u043f\u043e \u0434\u0440\u0443\u0433\u0438\u043c \u044f\u0437\u044b\u043a\u0430\u043c, \u0442\u043e \u0432\u044b \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u0435, \u0447\u0442\u043e Apple \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u0435\u0433\u043e \u0441\u0432\u043e\u0435\u043e\u0431\u0440\u0430\u0437\u043d\u043e (\u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u043a\u0430\u043a \u0438 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u0435 \u0415\u0432\u0440\u043e\u043a\u043e\u043c\u0438\u0441\u0441\u0438\u0438 \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043d\u0430 MicroUSB). \u041e\u043d\u0438 \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u044e\u0442 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u043e\u0432. \u0412\u044b, \u043c\u043e\u0436\u0435\u0442\u0435 \u0431\u044b\u0442\u044c, \u0437\u043d\u0430\u043a\u043e\u043c\u044b \u0441 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430\u043c\u0438 <code>UITableViewDelegate<\/code>, <code>UIScrollViewDelegate<\/code>, <code>NSCoding<\/code>, <code>NSCopying<\/code>. \u041a \u043f\u0440\u0438\u043c\u0435\u0440\u0443, \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b <code>NSCopying<\/code> \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043b\u044e\u0431\u043e\u043c\u0443 \u043a\u043b\u0430\u0441\u0441\u0443 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 <code>copy<\/code>.<\/p>\n<h3>\u041a\u0430\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0430\u0442\u0442\u0435\u0440\u043d \u00ab\u0410\u0434\u0430\u043f\u0442\u0435\u0440\u00bb<\/h3>\n<p>  \u0412\u044b\u0448\u0435\u0443\u043f\u043e\u043c\u044f\u043d\u0443\u0442\u044b\u0439 \u0433\u043e\u0440\u0438\u0437\u043e\u043d\u0442\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u043a\u0440\u043e\u043b\u043b \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage3\/b27\/ae2\/2d5\/b27ae22d5d1c9215861d81d3567569aa.png\"\/><\/p>\n<p>  \u0427\u0442\u043e\u0431\u044b \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u0442\u044c \u043a \u0435\u0433\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438, \u0441\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u043d\u043e\u0432\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u0438\u0437 \u0448\u0430\u0431\u043b\u043e\u043d\u0430 \u00abObjective-C class\u00bb (\u0435\u0449\u0451 \u043d\u0435 \u0437\u0430\u0431\u044b\u043b\u0438, \u043a\u0430\u043a?), \u043d\u0430\u0437\u043e\u0432\u0438\u0442\u0435 \u0435\u0433\u043e <code>HorizontalScroller<\/code> \u0438 \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0439\u0442\u0435 \u0435\u0433\u043e \u043e\u0442 <code>UIView<\/code>.<\/p>\n<p>  \u041e\u0442\u043a\u0440\u043e\u0439\u0442\u0435 <b>HorizontalScroller.h<\/b> \u0438 \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u043f\u043e\u0441\u043b\u0435 <code>@end<\/code>:<\/p>\n<pre><code class=\"cpp\">@protocol HorizontalScrollerDelegate &lt;NSObject&gt; \/\/ \u0442\u0443\u0442 \u0431\u0443\u0434\u0443\u0442 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u043c\u0435\u0442\u043e\u0434\u043e\u0432 @end <\/code><\/pre>\n<p>  \u042d\u0442\u0438\u043c \u043c\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b <code>HorizontalScrollerDelegate<\/code> \u2014 \u043d\u0430\u0441\u043b\u0435\u0434\u043d\u0438\u043a \u043e\u0442 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430 <code>NSObject<\/code> (\u0442\u0430\u043a\u0438\u043c \u0436\u0435 \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043a\u0430\u043a \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u044e\u0442\u0441\u044f \u043a\u043b\u0430\u0441\u0441\u044b). \u041e\u0431\u0449\u0435\u043f\u0440\u0438\u043d\u044f\u0442\u0430\u044f \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0430 \u2014 \u0447\u0442\u043e\u0431\u044b \u043a\u043b\u0430\u0441\u0441 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u043b \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0443 <code>NSObject<\/code> \u0438\u043b\u0438 \u0434\u0440\u0443\u0433\u043e\u043c\u0443 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0443, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u0442\u0441\u044f\/\u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0443 <code>NSObject<\/code>. \u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043c\u044b \u0441\u043c\u043e\u0436\u0435\u043c \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u0435 \u0432 <code>NSObject<\/code>, \u0434\u0435\u043b\u0435\u0433\u0430\u0442\u0443 \u043d\u0430\u0448\u0435\u0433\u043e <code>HorizontalScroller<\/code>. \u0421\u043a\u043e\u0440\u043e \u0443\u0432\u0438\u0434\u0438\u043c, \u043f\u043e\u0447\u0435\u043c\u0443 \u044d\u0442\u043e \u0432\u0430\u0436\u043d\u043e.<\/p>\n<p>  \u041e\u0431\u044a\u044f\u0432\u043b\u044f\u0435\u043c \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0438 \u043d\u0435\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u0435\u043b\u0435\u0433\u0430\u0442 \u0434\u043e\u043b\u0436\u0435\u043d \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c, \u043c\u0435\u0436\u0434\u0443 <code>@protocol<\/code> \u0438 <code>@end<\/code>:<\/p>\n<pre><code class=\"cpp\">@required  \/\/ \u0421\u043f\u0440\u043e\u0441\u0438\u0442\u044c \u0434\u0435\u043b\u0435\u0433\u0430\u0442\u0430, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0439 \u043c\u044b \u043f\u043e\u043a\u0430\u0436\u0435\u043c \u0432\u043d\u0443\u0442\u0440\u0438 \u0433\u043e\u0440\u0438\u0437\u043e\u043d\u0442\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0441\u043a\u0440\u043e\u043b\u043b\u0435\u0440\u0430 - (NSInteger)numberOfViewsForHorizontalScroller:(HorizontalScroller *)scroller;  \/\/ \u041f\u043e\u043f\u0440\u043e\u0441\u0438\u0442\u044c \u0434\u0435\u043b\u0435\u0433\u0430\u0442\u0430 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0443 &lt;index&gt; - (UIView *)horizontalScroller:(HorizontalScroller *)scroller viewAtIndex:(int)index;  \/\/ \u0421\u043e\u043e\u0431\u0449\u0438\u0442\u044c \u0434\u0435\u043b\u0435\u0433\u0430\u0442\u0443 \u043e \u043d\u0430\u0436\u0430\u0442\u0438\u0438 \u043d\u0430 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u043f\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0443 &lt;index&gt; - (void)horizontalScroller:(HorizontalScroller *)scroller clickedViewAtIndex:(int)index;  @optional  \/\/ \u0421\u043f\u0440\u043e\u0441\u0438\u0442\u044c \u0434\u0435\u043b\u0435\u0433\u0430\u0442\u0430, \u043a\u0430\u043a\u043e\u0435 \u0438\u0437 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0439 \u043e\u0442\u043e\u0431\u0440\u0430\u0437\u0438\u0442\u044c \u043f\u0440\u0438 \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u0438 \/\/ (\u043c\u0435\u0442\u043e\u0434 \u043d\u0435\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439, \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e 0, \u0435\u0441\u043b\u0438 \u0434\u0435\u043b\u0435\u0433\u0430\u0442 \u043d\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u043c\u0435\u0442\u043e\u0434) - (NSInteger)initialViewIndexForHorizontalScroller:(HorizontalScroller *)scroller; <\/code><\/pre>\n<p>  \u0417\u0434\u0435\u0441\u044c \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0438 \u043d\u0435\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b. \u041e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u2014 \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u044b \u0434\u0435\u043b\u0435\u0433\u0430\u0442\u043e\u043c, \u043e\u043d\u0438 \u043e\u0431\u044b\u0447\u043d\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442 \u0442\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b \u043a\u043b\u0430\u0441\u0441\u0443. \u0417\u0434\u0435\u0441\u044c \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0443 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 (\u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0439), \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u043f\u043e \u0434\u0430\u043d\u043d\u043e\u043c\u0443 \u0438\u043d\u0434\u0435\u043a\u0441\u0443, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u043f\u043e \u043d\u0430\u0436\u0430\u0442\u0438\u044e \u043d\u0430 \u044d\u043b\u0435\u043c\u0435\u043d\u0442.<\/p>\n<p>  \u041e\u043f\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u2014 \u0438\u043d\u0434\u0435\u043a\u0441 \u0441\u0442\u0430\u0440\u0442\u043e\u0432\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430. \u0415\u0441\u043b\u0438 \u0435\u0433\u043e \u043d\u0435 \u0443\u043a\u0430\u0437\u0430\u0442\u044c, \u0442\u043e <code>HorizontalScroller<\/code> \u043f\u0440\u0438 \u0441\u0442\u0430\u0440\u0442\u0435 \u043d\u0430\u0447\u043d\u0451\u0442 \u0441\u043d\u0430\u0447\u0430\u043b\u0430.<\/p>\n<p>  \u0414\u0430\u043b\u044c\u0448\u0435 \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0441\u043e\u0441\u043b\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043d\u0430\u0448\u0435\u0433\u043e \u0434\u0435\u043b\u0435\u0433\u0430\u0442\u0430 \u0432\u043d\u0443\u0442\u0440\u0438 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u043a\u043b\u0430\u0441\u0441\u0430 <code>HorizontalScroller<\/code>. \u041d\u043e \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430 \u0443 \u043d\u0430\u0441 \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u0441\u043b\u0435 \u043a\u043b\u0430\u0441\u0441\u0430, \u0442.\u0435. \u0435\u0449\u0451 \u043d\u0435 \u0432\u0438\u0434\u0435\u043d \u043d\u0430 \u043c\u043e\u043c\u0435\u043d\u0442 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f <code>HorizontalScroller<\/code>. \u0427\u0442\u043e \u0436\u0435 \u0434\u0435\u043b\u0430\u0442\u044c?<\/p>\n<p>  \u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u2014 \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435 (forward declaration) \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430 <code>HorizontalScrollerDelegate<\/code>. \u0427\u0442\u043e\u0431\u044b \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u0437\u043d\u0430\u043b, \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0439 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c (\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d \u043f\u043e\u0437\u0436\u0435). \u0414\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u043d\u0430\u0434 \u0441\u0442\u0440\u043e\u0447\u043a\u043e\u0439 <code>@interface<\/code>:<\/p>\n<pre><code class=\"cpp\">@protocol HorizontalScrollerDelegate; <\/code><\/pre>\n<p>  \u0412 \u0442\u043e\u043c \u0436\u0435 \u0444\u0430\u0439\u043b\u0435 <b>HorizontalScroller.h<\/b> \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0435\u0449\u0451 \u043f\u0430\u0440\u0443 \u0441\u0442\u0440\u043e\u043a \u043c\u0435\u0436\u0434\u0443 <code>@interface<\/code> \u0438 <code>@end<\/code>:<\/p>\n<pre><code class=\"cpp\">@property (weak) id&lt;HorizontalScrollerDelegate&gt; delegate;  - (void)reload; <\/code><\/pre>\n<p>  \u0417\u0430\u043c\u0435\u0442\u044c\u0442\u0435, \u043c\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 \u0430\u0442\u0440\u0438\u0431\u0443\u0442 <code>weak<\/code> (\u00ab\u0441\u043b\u0430\u0431\u044b\u0439\u00bb) \u043a \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0443 (\u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044e \u043d\u0430) <code>delegate<\/code>. \u042d\u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u0435\u0434\u043e\u0442\u0432\u0440\u0430\u0442\u0438\u0442\u044c \u00abretain-\u0437\u0430\u0446\u0438\u043a\u043b\u0438\u0432\u0430\u043d\u0438\u0435\u00bb. \u0415\u0441\u043b\u0438 \u043e\u0431\u044a\u0435\u043a\u0442 \u0445\u0440\u0430\u043d\u0438\u0442 \u0441\u0438\u043b\u044c\u043d\u044b\u0439 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u0434\u0435\u043b\u0435\u0433\u0430\u0442\u0430, \u0430 \u0434\u0435\u043b\u0435\u0433\u0430\u0442 \u0445\u0440\u0430\u043d\u0438\u0442 \u0441\u0438\u043b\u044c\u043d\u044b\u0439 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u043d\u0430 \u0442\u043e\u0442 \u043e\u0431\u044a\u0435\u043a\u0442, \u0442\u043e \u0432\u044b \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0435 \u0443\u0442\u0435\u0447\u043a\u0443 \u043f\u0430\u043c\u044f\u0442\u0438. \u041d\u0438 \u043e\u0434\u0438\u043d \u0438\u0437 \u0434\u0432\u0443\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u043e\u0441\u0432\u043e\u0431\u043e\u0434\u0438\u0442 \u043f\u0430\u043c\u044f\u0442\u044c.<\/p>\n<p>  (\u0415\u0441\u043b\u0438 \u043a\u0442\u043e-\u0442\u043e \u0437\u0430\u0431\u044b\u043b \u0440\u0430\u0437\u043d\u0438\u0446\u0443 \u043c\u0435\u0436\u0434\u0443 \u0441\u0438\u043b\u044c\u043d\u044b\u043c\u0438 \u0438 \u0441\u043b\u0430\u0431\u044b\u043c\u0438 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044f\u043c\u0438, \u0442\u043e \u043e\u043d\u0430 \u043e\u0431\u0441\u0443\u0436\u0434\u0430\u0435\u0442\u0441\u044f \u0432 \u0433\u043b\u0430\u0432\u0435 \u043f\u0440\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0430 \u00ab\u0424\u0430\u0441\u0430\u0434\u00bb \u043f\u043e\u0434 \u0441\u043f\u043e\u0439\u043b\u0435\u0440\u043e\u043c).<\/p>\n<p>  \u0422\u0438\u043f <code>id&lt;HorizontalScrollerDelegate&gt;<\/code> \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0434\u0435\u043b\u0435\u0433\u0430\u0442\u043e\u043c \u043c\u043e\u0436\u0435\u0442 \u0441\u0442\u0430\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442 \u043b\u044e\u0431\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0443 <code>HorizontalScrollerDelegate<\/code> (\u0447\u0442\u043e \u0434\u0430\u0451\u0442 \u043d\u0430\u043c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u044c \u0442\u0438\u043f\u043e\u0432).<\/p>\n<p>  \u041c\u0435\u0442\u043e\u0434 <code>reload<\/code> \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e <code>reloadData<\/code> \u0432 <code>UITableView<\/code>: \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043d\u043e\u0432\u043e \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0442\u044c \u0432\u0441\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u043d\u0443\u0436\u043d\u044b\u0435 \u0434\u043b\u044f \u0433\u043e\u0440\u0438\u0437\u043e\u043d\u0442\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0441\u043a\u0440\u043e\u043b\u043b\u0430.<\/p>\n<p>  \u0417\u0430\u043c\u0435\u043d\u0438\u0442\u0435 \u0432\u0441\u0451 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 <b>HorizontalScroller.m<\/b> \u043d\u0430 \u0442\u0430\u043a\u0443\u044e \u0437\u0430\u0433\u043e\u0442\u043e\u0432\u043a\u0443 (\u0434\u0430\u043b\u044c\u0448\u0435 \u043c\u044b \u0435\u0451 \u0431\u0443\u0434\u0435\u043c \u043d\u0430\u043f\u043e\u043b\u043d\u044f\u0442\u044c):<\/p>\n<pre><code class=\"cpp\">#import &quot;HorizontalScroller.h&quot;  \/\/ 1 #define VIEW_PADDING 10 #define VIEW_DIMENSIONS 100 #define VIEWS_OFFSET 100  \/\/ 2 @interface HorizontalScroller () &lt;UIScrollViewDelegate&gt; @end  \/\/ 3 @implementation HorizontalScroller {     UIScrollView * scroller; }  @end <\/code><\/pre>\n<p>  \u041f\u043e \u043f\u0443\u043d\u043a\u0442\u0430\u043c, \u0447\u0442\u043e \u043c\u044b \u0434\u0435\u043b\u0430\u0435\u043c:  <\/p>\n<ol>\n<li>\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u044b \u0434\u043b\u044f \u0443\u0434\u043e\u0431\u043d\u043e\u0439 \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0432\u043d\u0435\u0448\u043d\u0435\u0433\u043e \u0432\u0438\u0434\u0430 \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438. \u0420\u0430\u0437\u043c\u0435\u0440\u044b \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0439 \u0432\u043d\u0443\u0442\u0440\u0438 \u0441\u043a\u0440\u043e\u043b\u043b\u0430 \u0431\u0443\u0434\u0443\u0442 100\u0445100 \u043f\u0443\u043d\u043a\u0442\u043e\u0432 \u0441 \u043e\u0442\u0441\u0442\u0443\u043f\u043e\u043c 10 \u043f\u0443\u043d\u043a\u0442\u043e\u0432 \u043e\u0442 \u043f\u0440\u044f\u043c\u043e\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0445 \u043e\u0431\u0440\u0430\u043c\u043b\u044f\u0435\u0442.<br \/>  <i>(\u041f\u0443\u043d\u043a\u0442\u044b \u2014 \u043d\u0435 \u043f\u0443\u0442\u0430\u0442\u044c \u0441 \u043f\u0438\u043a\u0441\u0435\u043b\u044f\u043c\u0438! \u0412 iOS Drawing Concepts \u0435\u0441\u0442\u044c \u0440\u0430\u0437\u0434\u0435\u043b <a href=\"https:\/\/developer.apple.com\/library\/ios\/documentation\/2DDrawing\/Conceptual\/DrawingPrintingiOS\/GraphicsDrawingOverview\/GraphicsDrawingOverview.html#\/\/apple_ref\/doc\/uid\/TP40010156-CH14-SW7\">Points Versus Pixels<\/a>)<\/i>.<\/li>\n<li>\u041a\u043b\u0430\u0441\u0441 HorizontalScroller \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b UIScrollViewDelegate. \u0422\u0430\u043a \u043a\u0430\u043a HorizontalScroller \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 UIScrollView \u0434\u043b\u044f \u043f\u0440\u043e\u043a\u0440\u0443\u0442\u043a\u0438 \u043e\u0431\u043b\u043e\u0436\u0435\u043a \u0430\u043b\u044c\u0431\u043e\u043c\u043e\u0432, \u043e\u043d \u0434\u043e\u043b\u0436\u0435\u043d \u0437\u043d\u0430\u0442\u044c \u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0445 \u0441\u043e\u0431\u044b\u0442\u0438\u044f\u0445, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043a\u043e\u0433\u0434\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b \u043f\u0440\u043e\u043a\u0440\u0443\u0442\u043a\u0443.<\/li>\n<li>\u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0441\u043e\u0437\u0434\u0430\u0451\u043c scroll view.<\/li>\n<\/ol>\n<p>  \u0414\u0430\u043b\u044c\u0448\u0435 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438:<\/p>\n<pre><code class=\"cpp\">- (id)initWithFrame:(CGRect)frame {     self = [super initWithFrame:frame];     if (self)     {         scroller = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, frame.size.width, frame.size.height)];         scroller.delegate = self;         [self addSubview:scroller];         UITapGestureRecognizer * tapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(scrollerTapped:)];         [scroller addGestureRecognizer:tapRecognizer];     }     return self; } <\/code><\/pre>\n<p>  \u041e\u0431\u043b\u0430\u0441\u0442\u044c \u043f\u0440\u043e\u043a\u0440\u0443\u0442\u043a\u0438 (<code>scroller<\/code>) \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u0442 <code>HorizontalScroller<\/code>. \u041e\u0431\u044a\u0435\u043a\u0442 \u043a\u043b\u0430\u0441\u0441\u0430 <code>UITapGestureRecognizer<\/code> \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u0432\u0430\u0435\u0442 \u043a\u0430\u0441\u0430\u043d\u0438\u044f \u043d\u0430 \u0434\u0430\u043d\u043d\u043e\u043c ScrollView \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442, \u0431\u044b\u043b\u043e \u043b\u0438 \u043d\u0430\u0436\u0430\u0442\u0438\u0435 \u043d\u0430 \u043e\u0431\u043b\u043e\u0436\u043a\u0435 \u0430\u043b\u044c\u0431\u043e\u043c\u0430. \u0415\u0441\u043b\u0438 \u0431\u044b\u043b\u043e, \u0442\u043e \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u044f\u0435\u0442 \u0434\u0435\u043b\u0435\u0433\u0430\u0442\u0430 <code>HorizontalScroller<\/code>.<\/p>\n<p>  \u0414\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043c\u0435\u0442\u043e\u0434:<\/p>\n<pre><code class=\"cpp\">- (void)scrollerTapped:(UITapGestureRecognizer *)gesture {     CGPoint location = [gesture locationInView:gesture.view];     \/\/ \u041d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c enumerator, \u0442.\u043a. \u043d\u0435 \u0445\u043e\u0442\u0438\u043c \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u044f\u0442\u044c \u0432\u0441\u0435 \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f.     \/\/ \u041c\u044b \u0445\u043e\u0442\u0438\u043c \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0438\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0435 subviews, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438:     for (int index = 0; index &lt; [self.delegate numberOfViewsForHorizontalScroller:self]; index++)     {         UIView * view = scroller.subviews[index];         if (CGRectContainsPoint(view.frame, location))         {             [self.delegate horizontalScroller:self clickedViewAtIndex:index];             CGPoint offset = CGPointMake(view.frame.origin.x - self.frame.size.width\/2 + view.frame.size.width\/2, 0);             [scroller setContentOffset:offset animated:YES];             break;         }     } } <\/code><\/pre>\n<p>  \u0418\u0437 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u00ab\u0436\u0435\u0441\u0442\u00bb (<code>gesture<\/code>), \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0435\u043c\u043e\u0433\u043e \u0432 \u0432\u0438\u0434\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430, \u043c\u043e\u0436\u043d\u043e \u0438\u0437\u0432\u043b\u0435\u0447\u044c \u043f\u043e\u0437\u0438\u0446\u0438\u044e (<code>locationInView:<\/code>).<\/p>\n<p>  \u0414\u0430\u043b\u044c\u0448\u0435 \u0432\u044b\u0437\u0432\u0430\u043b\u0438 \u043c\u0435\u0442\u043e\u0434 \u0434\u0435\u043b\u0435\u0433\u0430\u0442\u0430 <code>numberOfViewsForHorizontalScroller:<\/code>. \u042d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 <code>HorizontalScroller<\/code> \u043d\u0435 \u0438\u043c\u0435\u0435\u0442 \u043d\u0438\u043a\u0430\u043a\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u0434\u0435\u043b\u0435\u0433\u0430\u0442\u0435, \u043a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0435\u043c\u0443 \u043c\u043e\u0436\u043d\u043e \u0441\u043c\u0435\u043b\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u044d\u0442\u043e \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 (\u0438\u0431\u043e \u0434\u0435\u043b\u0435\u0433\u0430\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0443 <code>HorizontalScrollerDelegate<\/code>).<\/p>\n<p>  \u0414\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0432\u043d\u0443\u0442\u0440\u0438 scroll view \u2014 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043b\u0438, \u0431\u044b\u043b\u043e \u043b\u0438 \u043d\u0430 \u043d\u0451\u043c \u043d\u0430\u0436\u0430\u0442\u0438\u0435, \u0432\u044b\u0437\u0432\u0430\u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>CGRectContainsPoint<\/code>. \u0415\u0441\u043b\u0438 \u043d\u0430\u0448\u043b\u0438 \u0442\u0430\u043a\u043e\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435, \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u043b\u0438 \u0434\u0435\u043b\u0435\u0433\u0430\u0442\u0443 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 <code>horizontalScroller:clickedViewAtIndex:<\/code> \u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b\u0438 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u043f\u043e \u0446\u0435\u043d\u0442\u0440\u0443 \u043e\u0431\u043b\u0430\u0441\u0442\u0438 \u043f\u0440\u043e\u043a\u0440\u0443\u0442\u043a\u0438.<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043a\u043e\u0434 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0441\u043a\u0440\u043e\u043b\u043b\u0435\u0440\u0435:<\/p>\n<pre><code class=\"cpp\">- (void)reload {     \/\/ 1 - \u043d\u0435\u0447\u0435\u0433\u043e \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0442\u044c, \u0435\u0441\u043b\u0438 \u043d\u0435\u0442 \u0434\u0435\u043b\u0435\u0433\u0430\u0442\u0430:     if (self.delegate == nil) return;      \/\/ 2 - \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u0432\u0441\u0435 subviews:     [scroller.subviews enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL * stop) {         [obj removeFromSuperview];     }];      \/\/ 3 - xValue - \u0441\u0442\u0430\u0440\u0442\u043e\u0432\u0430\u044f \u0442\u043e\u0447\u043a\u0430 \u0432\u0441\u0435\u0445 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0439 \u0432 \u0441\u043a\u0440\u043e\u043b\u043b\u0435\u0440\u0435:     CGFloat xValue = VIEWS_OFFSET;     for (int i = 0; i &lt; [self.delegate numberOfViewsForHorizontalScroller:self]; i++)     {         \/\/ 4 - \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0432 \u043d\u0443\u0436\u043d\u0443\u044e \u043f\u043e\u0437\u0438\u0446\u0438\u044e:         xValue += VIEW_PADDING;         UIView * view = [self.delegate horizontalScroller:self viewAtIndex:i];         view.frame = CGRectMake(xValue, VIEW_PADDING, VIEW_DIMENSIONS, VIEW_DIMENSIONS);         [scroller addSubview:view];         xValue += VIEW_DIMENSIONS + VIEW_PADDING;     }      \/\/ 5     [scroller setContentSize:CGSizeMake(xValue + VIEWS_OFFSET, self.frame.size.height)];      \/\/ 6 - \u0435\u0441\u043b\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d initialView, \u0446\u0435\u043d\u0442\u0440\u0438\u0440\u0443\u0435\u043c \u0435\u0433\u043e \u0432 \u0441\u043a\u0440\u043e\u043b\u043b\u0435\u0440\u0435:     if ([self.delegate respondsToSelector:@selector(initialViewIndexForHorizontalScroller:)])     {         int initialView = [self.delegate initialViewIndexForHorizontalScroller:self];         CGPoint offset = CGPointMake(initialView * (VIEW_DIMENSIONS + (2 * VIEW_PADDING)), 0);         [scroller setContentOffset:offset animated:YES];     } } <\/code><\/pre>\n<p>  \u041f\u0440\u043e\u0439\u0434\u0451\u043c\u0441\u044f \u043f\u043e \u044d\u0442\u043e\u043c\u0443 \u043a\u043e\u0434\u0443:  <\/p>\n<ol>\n<li>\u0415\u0441\u043b\u0438 \u043d\u0435\u0442 \u0434\u0435\u043b\u0435\u0433\u0430\u0442\u0430, \u0442\u043e \u043d\u0430\u043c \u0442\u0443\u0442 \u043d\u0435\u0447\u0435\u0433\u043e \u0434\u0435\u043b\u0430\u0442\u044c. \u0417\u0430\u0432\u0435\u0440\u0448\u0430\u0435\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u0430.<\/li>\n<li>\u0423\u0434\u0430\u043b\u044f\u0435\u043c \u0432\u0441\u0435 \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f (subviews), \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0435 \u0440\u0430\u043d\u0435\u0435.<br \/>  <i>(\u0418\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e, \u043a\u0430\u043a \u043f\u0435\u0440\u0435\u0432\u0435\u0441\u0442\u0438 \u00absubview\u00bb \u043f\u0440\u043e\u0449\u0435 \u0438 \u043d\u0435 \u043a\u043e\u0432\u0435\u0440\u043a\u0430\u044f \u0440\u0443\u0441\u0441\u043a\u0438\u0439 \u044f\u0437\u044b\u043a? \u041d\u0435 \u00ab\u043f\u043e\u0434\u0432\u0438\u0434\u044b\u00bb \u0436\u0435. \ud83d\ude42 \u2014 \u041f\u0440\u0438\u043c. \u043f\u0435\u0440.)<\/i><\/li>\n<li>\u0412\u0441\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u044b \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u044f (<code>VIEWS_OFFSET<\/code>). \u0412 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0435\u0435 \u0432\u0440\u0435\u043c\u044f \u044d\u0442\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <code>100<\/code> \u043f\u0443\u043d\u043a\u0442\u043e\u0432, \u0438 \u043e\u043d\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043b\u0435\u0433\u043a\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u043e \u0432 <code>#define<\/code> \u0432\u044b\u0448\u0435 \u0432 \u044d\u0442\u043e\u043c \u0444\u0430\u0439\u043b\u0435.<\/li>\n<li><code>HorizontalScroller<\/code> \u0441\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u0442 \u0443 \u0441\u0432\u043e\u0435\u0433\u043e \u0434\u0435\u043b\u0435\u0433\u0430\u0442\u0430 \u0432\u0441\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f (<code>UIView<\/code>) \u043e\u0434\u043d\u043e \u0437\u0430 \u0434\u0440\u0443\u0433\u0438\u043c, \u0438 \u0440\u0430\u0441\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442 \u0438\u0445 \u043f\u043e \u0433\u043e\u0440\u0438\u0437\u043e\u043d\u0442\u0430\u043b\u0438 \u043d\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u043c \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0438 \u0434\u0440\u0443\u0433 \u043e\u0442 \u0434\u0440\u0443\u0433\u0430.<\/li>\n<li>\u041a\u043e\u0433\u0434\u0430 \u0432\u0441\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043d\u0430 \u043c\u0435\u0441\u0442\u0435, \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0440\u0430\u0437\u043c\u0435\u0440 \u0441\u043a\u0440\u043e\u043b\u043b\u0435\u0440\u0430, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0442\u044c \u043f\u0440\u043e\u043a\u0440\u0443\u0442\u043a\u0443 \u043c\u0435\u0436\u0434\u0443 \u0432\u0441\u0435\u043c\u0438 \u0430\u043b\u044c\u0431\u043e\u043c\u0430\u043c\u0438.<\/li>\n<li><code>HorizontalScroller<\/code> \u0441\u043c\u043e\u0442\u0440\u0438\u0442: \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u043b\u0438 \u0434\u0435\u043b\u0435\u0433\u0430\u0442 \u043d\u0430 \u0441\u0435\u043b\u0435\u043a\u0442\u043e\u0440 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f <code>initialViewIndexForHorizontalScroller:<\/code>. \u0422\u0430\u043a\u0430\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043d\u0443\u0436\u043d\u0430, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u044d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0435\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c. \u0415\u0441\u043b\u0438 \u0434\u0435\u043b\u0435\u0433\u0430\u0442 \u043d\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u044d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434, \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0431\u0435\u0440\u0451\u0442\u0441\u044f <code>0<\/code>. \u042d\u0442\u0430 \u0447\u0430\u0441\u0442\u044c \u043a\u043e\u0434\u0430 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u0432\u0438\u0434 \u043f\u0440\u043e\u043a\u0440\u0443\u0442\u043a\u0438 \u043f\u043e \u0446\u0435\u043d\u0442\u0440\u0443 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0433\u043e \u0434\u0435\u043b\u0435\u0433\u0430\u0442\u043e\u043c (<code>initialView<\/code>).<\/li>\n<\/ol>\n<p>  \u041c\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c <code>reload<\/code> \u0432 \u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0441\u043b\u0438 \u0443 \u043d\u0430\u0441 \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0438\u0441\u044c \u0434\u0430\u043d\u043d\u044b\u0435. \u0422\u0430\u043a\u0436\u0435 \u044d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u0437\u0432\u0430\u0442\u044c, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c <code>HorizontalScroller<\/code> \u043a \u043d\u043e\u0432\u043e\u043c\u0443 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044e. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0442\u0430\u043a\u043e\u0439 \u043c\u0435\u0442\u043e\u0434 \u043a \u043a\u043b\u0430\u0441\u0441\u0443 <code>HorizontalScroller<\/code>:<\/p>\n<pre><code class=\"cpp\">- (void)didMoveToSuperview {     [self reload]; } <\/code><\/pre>\n<p>  \u0421\u043c\u044b\u0441\u043b \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f <code>didMoveToSuperview<\/code>, \u0434\u0443\u043c\u0430\u044e, \u043f\u043e\u043d\u044f\u0442\u0435\u043d \u0438\u0437 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f: \u043e\u043d\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0430\u0448\u0435\u043c\u0443 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044e, \u043a\u043e\u0433\u0434\u0430 \u043e\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043a \u043a\u0430\u043a\u043e\u043c\u0443-\u0442\u043e \u0434\u0440\u0443\u0433\u043e\u043c\u0443 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0434\u043e\u0447\u0435\u0440\u043d\u0435\u0433\u043e. \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0443\u0436\u043d\u043e \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0441\u043a\u0440\u043e\u043b\u043b\u0435\u0440\u0430.<\/p>\n<p>  \u041f\u043e\u0441\u043b\u0435\u0434\u043d\u044f\u044f \u0447\u0430\u0441\u0442\u044c \u043f\u0430\u0437\u043b\u0430 <code>HorizontalScroller<\/code> \u2014 \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u044b\u0439 \u0430\u043b\u044c\u0431\u043e\u043c \u0432\u0441\u0435\u0433\u0434\u0430 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u0446\u0435\u043d\u0442\u0440\u0435 scroll view. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f, \u043a\u043e\u0433\u0434\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0435\u0442 \u043f\u0440\u043e\u043a\u0440\u0443\u0442\u043a\u0443.<\/p>\n<p>  \u0414\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043c\u0435\u0442\u043e\u0434 (\u0432\u0441\u0451 \u043a \u0442\u043e\u043c\u0443 \u0436\u0435 \u0444\u0430\u0439\u043b\u0443, \u0434\u0430, <b>HorizontalScroller.m<\/b>):<\/p>\n<pre><code class=\"cpp\">- (void)centerCurrentView {     int xFinal = scroller.contentOffset.x + (VIEWS_OFFSET \/ 2) + VIEW_PADDING;     int viewIndex = xFinal \/ (VIEW_DIMENSIONS + (2 * VIEW_PADDING));     xFinal = viewIndex * (VIEW_DIMENSIONS + (2 * VIEW_PADDING));     [scroller setContentOffset:CGPointMake(xFinal, 0) animated:YES];     [self.delegate horizontalScroller:self clickedViewAtIndex:viewIndex]; } <\/code><\/pre>\n<p>  \u042d\u0442\u043e\u0442 \u043a\u043e\u0434 \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u0442 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043e\u0442 \u0446\u0435\u043d\u0442\u0440\u0430 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0438\u0438 \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u043a\u0440\u0443\u0442\u043a\u0438 (content offset), \u0430 \u0442\u0430\u043a\u0436\u0435 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u0432 (dimensions) \u0438 \u043e\u0442\u0441\u0442\u0443\u043f\u043e\u0432 (padding). \u041f\u043e\u0441\u043b\u0435\u0434\u043d\u044f\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u0438\u043c\u0435\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435: \u043a\u043e\u0433\u0434\u0430 \u043d\u0430\u0448 \u0430\u043b\u044c\u0431\u043e\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0451\u043d \u0432 \u0446\u0435\u043d\u0442\u0440, \u043d\u0430\u043a\u043e\u043d\u0435\u0446 \u0441\u043e\u043e\u0431\u0449\u0438\u0442\u044c \u0434\u0435\u043b\u0435\u0433\u0430\u0442\u0443, \u0447\u0442\u043e \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u043e\u0441\u044c.<\/p>\n<p>  \u0427\u0442\u043e\u0431\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043c\u043e\u043c\u0435\u043d\u0442, \u043a\u043e\u0433\u0434\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u043b \u0441\u043a\u0440\u043e\u043b\u043b\u0438\u0442\u044c, \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430 <code>UIScrollViewDelegate<\/code>:<\/p>\n<pre><code class=\"cpp\">- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate {     if (!decelerate)     {         [self centerCurrentView];     } }  - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {     [self centerCurrentView]; } <\/code><\/pre>\n<p>  <code>scrollViewDidEndDragging:willDecelerate:<\/code> \u0441\u043e\u043e\u0431\u0449\u0430\u0435\u0442 \u0434\u0435\u043b\u0435\u0433\u0430\u0442\u0443, \u043a\u043e\u0433\u0434\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u0435\u0442 \u043f\u0435\u0440\u0435\u0442\u0430\u0441\u043a\u0438\u0432\u0430\u043d\u0438\u0435. \u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 <code>decelerate<\/code> (\u00ab\u0437\u0430\u043c\u0435\u0434\u043b\u0435\u043d\u0438\u0435\u00bb) \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <code>true<\/code>, \u0435\u0441\u043b\u0438 \u0441\u043a\u0440\u043e\u043b\u043b \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0435\u0449\u0451 \u043d\u0435 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b\u0441\u044f, \u0430 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0435\u0442 \u0434\u0432\u0438\u0433\u0430\u0442\u044c\u0441\u044f \u00ab\u043f\u043e \u0438\u043d\u0435\u0440\u0446\u0438\u0438\u00bb. \u041a\u043e\u0433\u0434\u0430 \u043f\u0440\u043e\u043a\u0440\u0443\u0442\u043a\u0430 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f, \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u043f\u043e\u0448\u043b\u0451\u0442 \u043d\u0430\u043c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 <code>scrollViewDidEndDecelerating<\/code>. \u0412 \u043e\u0431\u043e\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0446\u0435\u043d\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u0430\u043b\u044c\u0431\u043e\u043c (<code>centerCurrentView<\/code>), \u0442\u0430\u043a \u043a\u0430\u043a \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u0430\u043b\u044c\u0431\u043e\u043c, \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u043c\u043e\u0433 \u0441\u043c\u0435\u043d\u0438\u0442\u044c\u0441\u044f \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043f\u0440\u043e\u043a\u0440\u0443\u0442\u043a\u0438.<\/p>\n<p>  \u0412\u0430\u0448 <code>HorizontalScroller<\/code> \u0433\u043e\u0442\u043e\u0432! \u0415\u0449\u0451 \u0440\u0430\u0437 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u0442\u0435 \u043d\u0430 \u044d\u0442\u043e\u0442 \u043a\u043e\u0434. \u0417\u0434\u0435\u0441\u044c \u043d\u0435\u0442 \u043d\u0438 \u043e\u0434\u043d\u043e\u0433\u043e \u0443\u043f\u043e\u043c\u0438\u043d\u0430\u043d\u0438\u044f <code>Album<\/code> \u0438\u043b\u0438 <code>AlbumView<\/code>. \u041f\u0440\u0435\u0432\u043e\u0441\u0445\u043e\u0434\u043d\u043e! \u042d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442, \u043d\u0430\u0448 \u043d\u043e\u0432\u044b\u0439 \u0441\u043a\u0440\u043e\u043b\u043b\u0435\u0440 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0441\u044f \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u043c \u043e\u0442 \u043a\u043e\u043d\u0442\u0435\u043d\u0442\u0430, \u0438 \u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c.<\/p>\n<p>  \u0412\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u0435 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u0447\u0442\u043e\u0431\u044b \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u0432\u0441\u0451 \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u0442\u0441\u044f.<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c, \u043a\u043e\u0433\u0434\u0430 \u0433\u043e\u0440\u0438\u0437\u043e\u043d\u0442\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u043a\u0440\u043e\u043b\u043b \u0433\u043e\u0442\u043e\u0432, \u0441\u0430\u043c\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0432 \u043d\u0430\u0448\u0435\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438! \u041e\u0442\u043a\u0440\u043e\u0439\u0442\u0435 <b>ViewController.m<\/b> \u0438 \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u0435 \u0432 \u043d\u0435\u0433\u043e 2 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u0447\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u0430:<\/p>\n<pre><code class=\"cpp\">#import &quot;HorizontalScroller.h&quot; #import &quot;AlbumView.h&quot; <\/code><\/pre>\n<p>  \u041d\u0438\u0436\u0435 \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 <code>HorizontalScrollerDelegate<\/code> \u043a \u0441\u043f\u0438\u0441\u043a\u0443 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 <code>ViewController<\/code>:<\/p>\n<pre><code class=\"cpp\">@interface ViewController () &lt;UITableViewDataSource, UITableViewDelegate, HorizontalScrollerDelegate&gt; <\/code><\/pre>\n<p>  \u0414\u043e\u0431\u0430\u0432\u0438\u0442 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430 \u00ab\u0441\u043a\u0440\u043e\u043b\u043b\u0435\u0440\u00bb \u0432 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u0430 (\u043c\u0435\u0436\u0434\u0443 \u0444\u0438\u0433\u0443\u0440\u043d\u044b\u043c\u0438 \u0441\u043a\u043e\u0431\u043a\u0430\u043c\u0438):<\/p>\n<pre><code class=\"cpp\">HorizontalScroller * scroller; <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u044b \u0434\u0435\u043b\u0435\u0433\u0430\u0442\u0430. \u0412\u044b \u0443\u0434\u0438\u0432\u0438\u0442\u0435\u0441\u044c, \u043a\u0430\u043a \u043c\u0430\u043b\u043e \u043a\u043e\u0434\u0430 \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0439!<\/p>\n<p>  \u0414\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u043a\u043e\u0434 \u0432 <b>ViewController.m<\/b>:<\/p>\n<pre><code class=\"cpp\">#pragma mark - HorizontalScrollerDelegate methods  - (void)horizontalScroller:(HorizontalScroller *)scroller clickedViewAtIndex:(int)index {     currentAlbumIndex = index;     [self showDataForAlbumAtIndex:index]; } <\/code><\/pre>\n<p>  \u041e\u043d \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0445\u0440\u0430\u043d\u0438\u0442 \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u0430\u043b\u044c\u0431\u043e\u043c, \u0438 \u0437\u0430\u0442\u0435\u043c \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 showDataForAlbumAtIndex: \u0434\u043b\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u043e \u043d\u043e\u0432\u043e\u043c\u0443 \u0430\u043b\u044c\u0431\u043e\u043c\u0443.<\/p>\n<p>  <b>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435.<\/b> \u0418\u043d\u043e\u0433\u0434\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u043c\u043e\u0436\u043d\u043e \u0441\u0433\u0440\u0443\u043f\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0434 \u043e\u0434\u043d\u0438\u043c \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u043e\u043c. \u042d\u0442\u0438\u043c \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u043e\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u0430 <code>#pragma mark<\/code>. \u041a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u0435\u0451 \u0438\u0433\u043d\u043e\u0440\u0438\u0440\u0443\u0435\u0442, \u043d\u043e \u0432\u044b \u0443\u0432\u0438\u0434\u0438\u0442\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432 \u043f\u0430\u043d\u0435\u043b\u0438 \u043d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u0438 \u0432 IDE \u2014 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043d\u0430\u0448\u0435\u0439 \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u044b \u0436\u0438\u0440\u043d\u044b\u043c \u0448\u0440\u0438\u0444\u0442\u043e\u043c. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 AppCode \u043f\u043e \u043d\u0430\u0436\u0430\u0442\u0438\u044e <b>\u2318F12<\/b>:<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage3\/4a6\/d33\/9ce\/4a6d339ce448c4b1320df68e1b9b4363.png\"\/><\/p>\n<p>  \u0422\u0430\u043a\u0430\u044f \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u0430\u0446\u0438\u044f \u043a\u043e\u0434\u0430, \u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u0441\u0438\u043b\u044c\u043d\u043e \u0443\u043f\u0440\u043e\u0449\u0430\u0435\u0442 \u043d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u044e \u043f\u043e \u0444\u0430\u0439\u043b\u0443.<\/p>\n<p>  \u0417\u0430\u0442\u0435\u043c \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u043a\u043e\u0434:<\/p>\n<pre><code class=\"cpp\">- (NSInteger)numberOfViewsForHorizontalScroller:(HorizontalScroller *)scroller {     return allAlbums.count; } <\/code><\/pre>\n<p>  \u041f\u043e\u043c\u043d\u0438\u0442\u0435? \u042d\u0442\u043e \u043c\u0435\u0442\u043e\u0434 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0449\u0438\u0439 \u0447\u0438\u0441\u043b\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0439 \u0432 \u043d\u0430\u0448\u0435\u043c scroll view. \u041c\u044b \u0445\u043e\u0442\u0438\u043c \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0442\u044c \u043e\u0431\u043b\u043e\u0436\u043a\u0438 \u0432\u0441\u0435\u0445 \u0430\u043b\u044c\u0431\u043e\u043c\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u043e\u0431\u0449\u0435\u0435 \u0447\u0438\u0441\u043b\u043e \u0430\u043b\u044c\u0431\u043e\u043c\u043e\u0432.<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043a\u043e\u0434:<\/p>\n<pre><code class=\"cpp\">- (UIView *)horizontalScroller:(HorizontalScroller *)scroller viewAtIndex:(int)index {     Album * album = allAlbums[index];     return [[AlbumView alloc] initWithFrame:CGRectMake(0.f, 0.f, 100.f, 100.f) albumCover:album.coverUrl]; } <\/code><\/pre>\n<p>  \u0417\u0434\u0435\u0441\u044c \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0451\u043c \u043d\u043e\u0432\u044b\u0439 <code>AlbumView<\/code> \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0451\u043c \u0435\u0433\u043e \u0432 <code>HorizontalScroller<\/code>.<\/p>\n<p>  \u0412\u0441\u0435\u0433\u043e-\u0442\u043e! \u0422\u0440\u0438 \u043a\u043e\u0440\u043e\u0442\u043a\u0438\u0445 \u043c\u0435\u0442\u043e\u0434\u0430, \u0447\u0442\u043e\u0431\u044b \u043e\u0442\u043e\u0431\u0440\u0430\u0437\u0438\u0442\u044c \u043a\u0440\u0430\u0441\u0438\u0432\u044b\u0439 \u0433\u043e\u0440\u0438\u0437\u043e\u043d\u0442\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u043a\u0440\u043e\u043b\u043b\u0435\u0440!<\/p>\n<p>  \u0414\u0430, \u0438 \u043c\u044b \u0432\u0441\u0451 \u0440\u0430\u0432\u043d\u043e \u0434\u043e\u043b\u0436\u043d\u044b \u0441\u043e\u0437\u0434\u0430\u0442\u044c (\u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e) \u0441\u043a\u0440\u043e\u043b\u043b\u0435\u0440 \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0435\u0433\u043e \u043a \u0433\u043b\u0430\u0432\u043d\u043e\u043c\u0443 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044e. \u041d\u043e \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043c\u0435\u0442\u043e\u0434:<\/p>\n<pre><code class=\"cpp\">- (void)reloadScroller {     allAlbums = [[LibraryAPI sharedInstance] getAlbums];     if (currentAlbumIndex &lt; 0)         currentAlbumIndex = 0;     else if (currentAlbumIndex &gt;= allAlbums.count)         currentAlbumIndex = allAlbums.count - 1;     [scroller reload];      [self showDataForAlbumAtIndex:currentAlbumIndex]; } <\/code><\/pre>\n<p>  \u042d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e \u0430\u043b\u044c\u0431\u043e\u043c\u0443 \u0447\u0435\u0440\u0435\u0437 <code>LibraryAPI<\/code>, \u0430 \u0437\u0430\u0442\u0435\u043c \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u0442\u0435\u043a\u0443\u0449\u0435\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435. \u041d\u0430 \u0432\u0441\u044f\u043a\u0438\u0439 \u0441\u043b\u0443\u0447\u0430\u0439 \u2014 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043d\u0430 \u0432\u044b\u0445\u043e\u0434 \u0437\u0430 \u0433\u0440\u0430\u043d\u0438\u0446\u044b \u043c\u0430\u0441\u0441\u0438\u0432\u0430.<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0441\u043a\u0440\u043e\u043b\u043b\u0435\u0440, \u0434\u043e\u0431\u0430\u0432\u0438\u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434 \u0432 <code>viewDidLoad<\/code> \u043f\u0435\u0440\u0435\u0434 \u0441\u0442\u0440\u043e\u0447\u043a\u043e\u0439 <code>[self showDataForAlbumAtIndex:currentAlbumIndex];<\/code><\/p>\n<pre><code class=\"cpp\">scroller = [[HorizontalScroller alloc] initWithFrame:CGRectMake(0.f, 20.f, self.view.frame.size.width, 120.f)]; scroller.backgroundColor = [UIColor colorWithRed:0.24f green:0.35f blue:0.49f alpha:1]; scroller.delegate = self; [self.view addSubview:scroller];  [self reloadScroller]; <\/code><\/pre>\n<p>  \u042d\u0442\u043e\u0442 \u043a\u043e\u0434 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u043d\u043e\u0432\u044b\u0439 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 <code>HorizontalScroller<\/code>, \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u0446\u0432\u0435\u0442 \u0444\u043e\u043d\u0430, \u043d\u0430\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u0434\u0435\u043b\u0435\u0433\u0430\u0442\u043e\u043c \u0441\u0435\u0431\u044f. \u0417\u0430\u0442\u0435\u043c \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043a\u0440\u043e\u043b\u043b\u0435\u0440 \u043d\u0430 \u0433\u043b\u0430\u0432\u043d\u044b\u0439 \u044d\u043a\u0440\u0430\u043d \u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442 \u0432 \u043d\u0451\u043c \u0434\u0430\u043d\u043d\u044b\u0435.<\/p>\n<p>  <b>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435.<\/b> \u0415\u0441\u043b\u0438 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b \u0441\u0438\u043b\u044c\u043d\u043e \u0440\u0430\u0437\u0440\u0430\u0441\u0442\u0430\u0435\u0442\u0441\u044f, \u043f\u043e\u0434\u0443\u043c\u0430\u0439\u0442\u0435 \u043e \u0442\u043e\u043c, \u0447\u0442\u043e\u0431\u044b \u0440\u0430\u0437\u0431\u0438\u0442\u044c \u0435\u0433\u043e \u043d\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0431\u043e\u043b\u0435\u0435 \u043c\u0435\u043b\u043a\u0438\u0445. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <code>UITableViewDelegate<\/code> \u0438 <code>UITableViewDataSource<\/code>. \u041e\u043d\u0438 \u043e\u0431\u0430 \u2014 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u044b <code>UITableView<\/code>, \u0442.\u0435. \u0442\u0435\u0445\u043d\u0438\u0447\u0435\u0441\u043a\u0438 \u043c\u043e\u0433\u043b\u0438 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0432 \u043e\u0434\u043d\u043e\u043c \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0435, \u043d\u043e \u0440\u0430\u0437\u0431\u0438\u0442\u044b \u0434\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430. \u0421\u0442\u0430\u0440\u0430\u0439\u0442\u0435\u0441\u044c \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u044b \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u043a\u0430\u0436\u0434\u044b\u0439 \u043e\u0442\u0432\u0435\u0447\u0430\u043b \u0437\u0430 \u0441\u0432\u043e\u044e \u043e\u0431\u043b\u0430\u0441\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u0430.<\/p>\n<p>  \u041f\u043e\u0441\u0442\u0440\u043e\u0439\u0442\u0435 \u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 \u043f\u0440\u043e\u0435\u043a\u0442. \u0427\u0443\u0434\u0435\u0441\u043d\u044b\u0439 \u0433\u043e\u0440\u0438\u0437\u043e\u043d\u0442\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u043a\u0440\u043e\u043b\u043b:<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage3\/dff\/3a8\/57f\/dff3a857fb0ff1069510f798f6747552.png\"\/><\/p>\n<p>  \u0422\u0430\u043a, \u0441\u0442\u043e\u043f. \u0421\u043a\u0440\u043e\u043b\u043b \u0435\u0441\u0442\u044c. \u0410 \u0433\u0434\u0435 \u043e\u0431\u043b\u043e\u0436\u043a\u0438?<\/p>\n<p>  \u0410, \u0442\u043e\u0447\u043d\u043e! \u041c\u044b \u0436\u0435 \u0435\u0449\u0451 \u043d\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u043b\u0438 \u043a\u043e\u0434 \u0434\u043b\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u043e\u0431\u043b\u043e\u0436\u0435\u043a. \u041d\u0430\u043c \u043d\u0430\u0434\u043e \u043f\u0440\u0438\u0434\u0443\u043c\u0430\u0442\u044c, \u043a\u0430\u043a \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0442\u044c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f. \u0422\u0430\u043a \u043a\u0430\u043a \u0432\u0435\u0441\u044c \u043d\u0430\u0448 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0441\u0435\u0440\u0432\u0438\u0441\u0430\u043c \u0438\u0434\u0451\u0442 \u0447\u0435\u0440\u0435\u0437 <code>LibraryAPI<\/code>, \u043d\u043e\u0432\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u043f\u0440\u0430\u0432\u0438\u0442\u044c\u0441\u044f \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0443\u0434\u0430. \u041d\u043e \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0443\u0436\u043d\u043e \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u043e\u043c\u0435\u043d\u0442\u043e\u0432:<\/p>\n<p>  1. <code>AlbumView<\/code> \u043d\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0441 <code>LibraryAPI<\/code>. \u041c\u044b \u0436\u0435 \u043d\u0435 \u0445\u043e\u0442\u0438\u043c \u0441\u043c\u0435\u0448\u0438\u0432\u0430\u0442\u044c \u043a\u043e\u0434 UI \u0441 \u0441\u0435\u0442\u0435\u0432\u044b\u043c \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435\u043c, \u0442\u0430\u043a?<br \/>  2. \u041f\u043e \u0442\u043e\u0439 \u0436\u0435 \u043f\u0440\u0438\u0447\u0438\u043d\u0435 <code>LibraryAPI<\/code> \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u0430 \u0437\u043d\u0430\u0442\u044c \u043e <code>AlbumView<\/code>.<br \/>  3. <code>LibraryAPI<\/code> \u0434\u043e\u043b\u0436\u043d\u0430 \u0441\u043e\u043e\u0431\u0449\u0438\u0442\u044c <code>AlbumView<\/code>, \u043a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0431\u043b\u043e\u0436\u043a\u0438 \u0437\u0430\u0433\u0440\u0443\u0437\u044f\u0442\u0441\u044f, \u0447\u0442\u043e\u0431\u044b <code>AlbumView<\/code> \u0438\u0445 \u043e\u0442\u043e\u0431\u0440\u0430\u0437\u0438\u043b.<\/p>\n<p>  \u0412\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043a\u0430\u043a \u0433\u043e\u043b\u043e\u0432\u043e\u043b\u043e\u043c\u043a\u0430? \u041d\u0435 \u043e\u0442\u0447\u0430\u0438\u0432\u0430\u0439\u0442\u0435\u0441\u044c! \u041d\u0430\u043c \u043d\u0430 \u043f\u043e\u043c\u043e\u0449\u044c \u0441\u043f\u0435\u0448\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043f\u0430\u0442\u0442\u0435\u0440\u043d \u2014 <\/p>\n<h2>\u041d\u0430\u0431\u043b\u044e\u0434\u0430\u0442\u0435\u043b\u044c<\/h2>\n<p>  \u0412 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0435 \u00ab\u041d\u0430\u0431\u043b\u044e\u0434\u0430\u0442\u0435\u043b\u044c\u00bb \u043e\u0434\u0438\u043d \u043e\u0431\u044a\u0435\u043a\u0442 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u044f\u0435\u0442 \u0434\u0440\u0443\u0433\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u043e\u0431 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f\u0445 \u0441\u0432\u043e\u0435\u0433\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f. \u041e\u0431\u044a\u0435\u043a\u0442\u0430\u043c, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u043c \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0437\u043d\u0430\u0442\u044c \u0434\u0440\u0443\u0433 \u043e \u0434\u0440\u0443\u0433\u0435 \u2014 \u044d\u0442\u043e \u0438 \u0435\u0441\u0442\u044c \u0441\u043b\u0430\u0431\u043e-\u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0439 (\u0430 \u0437\u043d\u0430\u0447\u0438\u0442, \u0433\u0438\u0431\u043a\u0438\u0439) \u043a\u043e\u0434. \u042d\u0442\u043e\u0442 \u043f\u0430\u0442\u0442\u0435\u0440\u043d \u0447\u0430\u0449\u0435 \u0432\u0441\u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442, \u043a\u043e\u0433\u0434\u0430 \u043d\u0430\u0434\u043e \u0443\u0432\u0435\u0434\u043e\u043c\u0438\u0442\u044c \u00ab\u0437\u0430\u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043b\u0438\u0446\u00bb \u043e\u0431 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 <i>\u0441\u0432\u043e\u0439\u0441\u0442\u0432<\/i> \u043d\u0430\u0448\u0435\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430.<\/p>\n<p>  \u041e\u0431\u044b\u0447\u043d\u043e \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0442\u0435\u043b\u044c \u00ab\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442\u00bb \u0441\u0432\u043e\u0439 \u0438\u043d\u0442\u0435\u0440\u0435\u0441 \u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0438 \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430. \u041a\u043e\u0433\u0434\u0430 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f, \u0432\u0441\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b-\u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0442\u0435\u043b\u0438 \u0431\u0443\u0434\u0443\u0442 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u044b \u043e\u0431 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438. \u0421\u0435\u0440\u0432\u0438\u0441 push-\u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0439 Apple \u2014 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0442\u0430\u043a\u043e\u0439 \u0441\u0445\u0435\u043c\u044b.<\/p>\n<p>  \u0415\u0441\u043b\u0438 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u043f\u0440\u0438\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u0438 MVC (\u043f\u043e\u0434\u0441\u043a\u0430\u0437\u043a\u0430: \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435) \u2014 \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u043c\u0435\u0436\u0434\u0443 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438 \u041c\u043e\u0434\u0435\u043b\u044c \u0438 \u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435, \u043d\u043e \u2014 \u0431\u0435\u0437 \u043f\u0440\u044f\u043c\u044b\u0445 \u0441\u0441\u044b\u043b\u043e\u043a \u0434\u0440\u0443\u0433 \u043d\u0430 \u0434\u0440\u0443\u0433\u0430! \u0418 \u0437\u0434\u0435\u0441\u044c \u0432\u0441\u0442\u0443\u043f\u0430\u0435\u0442 \u0432 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u043f\u0430\u0442\u0442\u0435\u0440\u043d \u00ab\u041d\u0430\u0431\u043b\u044e\u0434\u0430\u0442\u0435\u043b\u044c\u00bb.<\/p>\n<p>  Cocoa \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u044d\u0442\u043e\u0442 \u043f\u0430\u0442\u0442\u0435\u0440\u043d \u0434\u0432\u0443\u043c\u044f \u043f\u043e\u0445\u043e\u0436\u0438\u043c\u0438 \u0441\u043f\u043e\u0441\u043e\u0431\u0430\u043c\u0438: \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f (Notifications) \u0438 Key-Value Observing (KVO).<\/p>\n<h3>\u0423\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f<\/h3>\n<p>  (\u0422\u043e\u043b\u044c\u043a\u043e \u043d\u0435 \u043f\u0443\u0442\u0430\u0439\u0442\u0435 \u0441 Push \u0438 \u0441 \u043f\u0440\u043e\u0447\u0438\u043c\u0438 \u0432\u044b\u0441\u043a\u0430\u043a\u0438\u0432\u0430\u044e\u0449\u0438\u043c\u0438 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f\u043c\u0438. \u041c\u044b \u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438.) \u0423\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u044b \u043d\u0430 \u043c\u043e\u0434\u0435\u043b\u0438 \u00ab\u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0430\u2014\u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u044f\u00bb. \u0421\u043e\u0433\u043b\u0430\u0441\u043d\u043e \u0435\u0439, \u043e\u0431\u044a\u0435\u043a\u0442 \u00ab\u0438\u0437\u0434\u0430\u0442\u0435\u043b\u044c\u00bb (publisher) \u0440\u0430\u0441\u0441\u044b\u043b\u0430\u0435\u0442 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u043f\u043e\u0434\u043f\u0438\u0441\u0447\u0438\u043a\u0430\u043c (subscribers \/ listeners). \u0418\u0437\u0434\u0430\u0442\u0435\u043b\u044c \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u0437\u043d\u0430\u0442\u044c \u043e \u043f\u043e\u0434\u043f\u0438\u0441\u0447\u0438\u043a\u0430\u0445.<\/p>\n<p>  \u0423\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f \u0430\u043a\u0442\u0438\u0432\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f Apple. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043a\u043e\u0433\u0434\u0430 iOS \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0438\u043b\u0438 \u0441\u043a\u0440\u044b\u0432\u0430\u0435\u0442 \u043a\u043b\u0430\u0432\u0438\u0430\u0442\u0443\u0440\u0443, \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0440\u0430\u0441\u0441\u044b\u043b\u0430\u0435\u0442 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0435: <code>UIKeyboardWillShowNotification<\/code> \u0438\u043b\u0438 <code>UIKeyboardWillHideNotification<\/code>, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e. \u041a\u043e\u0433\u0434\u0430 \u0432\u0430\u0448\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0443\u0445\u043e\u0434\u0438\u0442 \u0432 \u0444\u043e\u043d\u043e\u0432\u044b\u0439 \u0440\u0435\u0436\u0438\u043c, \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0435 <code>UIApplicationDidEnterBackgroundNotification<\/code>.<\/p>\n<p>  <b>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435.<\/b> \u041e\u0442\u043a\u0440\u043e\u0439\u0442\u0435 <b>UIApplication.h<\/b>, \u0432 \u043a\u043e\u043d\u0446\u0435 \u0444\u0430\u0439\u043b\u0430 \u0432\u044b \u0443\u0432\u0438\u0434\u0438\u0442\u0435 \u043e\u0433\u0440\u043e\u043c\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0439, \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c\u044b\u0445 \u0441\u0438\u0441\u0442\u0435\u043c\u043e\u0439.  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041a\u0430\u043a \u0435\u0433\u043e \u043e\u0442\u043a\u0440\u044b\u0442\u044c?<\/b><\/p>\n<div class=\"spoiler_text\"><b>1 \u0441\u043f\u043e\u0441\u043e\u0431:<\/b> \u043d\u0430\u043f\u0438\u0448\u0438\u0442\u0435 \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u043b\u044e\u0431\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430:<\/p>\n<pre><code class=\"cpp\">#import &lt;UIKit\/UIApplication.h&gt; <\/code><\/pre>\n<p>  \u0418 \u043f\u0440\u0438 \u043d\u0430\u0436\u0430\u0442\u043e\u0439 \u043a\u043d\u043e\u043f\u043a\u0435 <b>\u2318<\/b> \u0449\u0451\u043b\u043a\u043d\u0438\u0442\u0435 \u043d\u0430 <code>UIApplication.h<\/code>.<\/p>\n<p>  <b>2 \u0441\u043f\u043e\u0441\u043e\u0431:<\/b> \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u043d\u0430\u0439\u0434\u0438\u0442\u0435 \u043f\u0430\u043f\u043a\u0443 <b>Frameworks<\/b> (\u0441\u043f\u0438\u0441\u043e\u043a \u0441\u0441\u044b\u043b\u043e\u043a \u043d\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0438), \u0440\u0430\u0437\u0432\u0435\u0440\u043d\u0438\u0442\u0435 <b>UIKit.framework<\/b> (\u043e\u043d\u0430 \u0442\u0443\u0442 \u0435\u0441\u0442\u044c, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043e\u043d\u0430 \u0431\u044b\u043b\u0430 \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0430 \u0432 \u043f\u0440\u043e\u0435\u043a\u0442 \u0430\u0432\u0442\u043e\u0440\u043e\u043c) \u0438 \u0442\u0430\u043c \u043d\u0430\u0439\u0434\u0438\u0442\u0435 \u0444\u0430\u0439\u043b <b>UIApplication.h<\/b>:<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage3\/1a3\/2f9\/6e4\/1a32f96e4ed9681b5f7b8f7df8773ab8.png\"\/><\/div>\n<\/div>\n<p>  <\/p>\n<h4>\u041a\u0430\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f<\/h4>\n<p>  \u041f\u0435\u0440\u0435\u0439\u0434\u0438\u0442\u0435 \u043a <b>AlbumView.m<\/b> \u0438 \u0432\u0441\u0442\u0430\u0432\u044c\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434 \u0432 <code>initWithFrame:albumCover:<\/code> \u043f\u043e\u0441\u043b\u0435 <code>[self addSubview:indicator];<\/code><\/p>\n<pre><code class=\"cpp\">[[NSNotificationCenter defaultCenter] postNotificationName:@&quot;BLDownloadImageNotification&quot;                                                     object:self                                                   userInfo:@{@&quot;coverUrl&quot;:albumCover,                                                              @&quot;imageView&quot;:coverImage}]; <\/code><\/pre>\n<p>  \u042d\u0442\u0430 \u0441\u0442\u0440\u043e\u043a\u0430 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0435 \u0447\u0435\u0440\u0435\u0437 \u0441\u0438\u043d\u0433\u043b\u0442\u043e\u043d <code>NSNotificationCenter<\/code>. \u0423\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 URL \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c, \u0438 <code>UIImageView<\/code>, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u044d\u0442\u043e \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435. \u0412\u043e\u0442 \u0438 \u0432\u0441\u0451, \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0437\u043d\u0430\u0442\u044c \u043d\u0430\u0448\u0435\u043c\u0443 \u00ab\u043f\u043e\u0434\u043f\u0438\u0441\u0447\u0438\u043a\u0443\u00bb, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u043b\u0443\u0447\u0438\u0442 \u044d\u0442\u043e \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0435, \u0447\u0442\u043e\u0431\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0443 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438.<\/p>\n<p>  \u0414\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443 \u0432 <b>LibraryAPI.m<\/b> \u0432 \u043c\u0435\u0442\u043e\u0434 <code>init<\/code>, \u0441\u0440\u0430\u0437\u0443 \u043f\u043e\u0441\u043b\u0435 <code>isOnline = NO<\/code>:<\/p>\n<pre><code class=\"cpp\">[[NSNotificationCenter defaultCenter] addObserver:self                                          selector:@selector(downloadImage:)                                              name:@&quot;BLDownloadImageNotification&quot;                                            object:nil]; <\/code><\/pre>\n<p>  \u042d\u0442\u043e \u0432\u0442\u043e\u0440\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u2014 \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0442\u0435\u043b\u044c (\u043f\u043e\u0434\u043f\u0438\u0441\u0447\u0438\u043a). \u041a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437, \u043a\u043e\u0433\u0434\u0430 \u043a\u043b\u0430\u0441\u0441 <code>AlbumView<\/code> \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0435 <code>&quot;BLDownloadImageNotification&quot;<\/code>, \u0442.\u043a. <code>LibraryAPI<\/code> \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043b\u0430\u0441\u044c \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0442\u0435\u043b\u044f \u043d\u0430 \u044d\u0442\u043e \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0435, \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0443\u0432\u0435\u0434\u043e\u043c\u0438\u0442 <code>LibraryAPI<\/code>. \u0412 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c, <code>LibraryAPI<\/code> \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 <code>downloadImage:<\/code>.<\/p>\n<p>  \u0412 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0438 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f \u043f\u0440\u0435\u0444\u0438\u043a\u0441 \u00abBL\u00bb = \u0441\u043e\u043a\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u043e\u0442 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u043f\u0440\u043e\u0435\u043a\u0442\u0430 <code>BlueLibrary<\/code> \u0434\u043b\u044f \u043e\u0431\u043b\u0435\u0433\u0447\u0435\u043d\u0438\u044f \u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433\u0430.<\/p>\n<p>  \u041d\u043e \u043f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u043c\u044b \u043f\u0435\u0440\u0435\u0439\u0434\u0451\u043c \u043a \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0442\u0435\u043b\u044e, \u0435\u0449\u0451 \u043e\u0434\u043d\u0430 \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0430\u044f \u0434\u0435\u0442\u0430\u043b\u044c: \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043e\u0442\u043f\u0438\u0441\u0430\u0442\u044c\u0441\u044f \u043e\u0442 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f, \u043a\u043e\u0433\u0434\u0430 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043d\u0430\u0448\u0435\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u043e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0430\u0435\u0442 \u043f\u0430\u043c\u044f\u0442\u044c. \u0415\u0441\u043b\u0438 \u044d\u0442\u043e\u0433\u043e \u043d\u0435 \u0441\u0434\u0435\u043b\u0430\u0442\u044c, \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u043c\u043e\u0436\u0435\u0442 \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u0443, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443\u0436\u0435 \u0431\u044b\u043b \u0432\u044b\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0435\u043d \u0438\u0437 \u043f\u0430\u043c\u044f\u0442\u0438 (deallocated), \u0447\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043a \u043f\u0430\u0434\u0435\u043d\u0438\u044e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0415\u0441\u043b\u0438 \u0431\u044b \u041f\u043e\u0447\u0442\u0430 \u0420\u043e\u0441\u0441\u0438\u0438 \u0431\u044b\u043b\u0430 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0430 \u043d\u0430 Objective C<\/b><\/p>\n<div class=\"spoiler_text\">\u0415\u0441\u043b\u0438 \u0447\u0435\u043b\u043e\u0432\u0435\u043a \u0443\u043c\u0438\u0440\u0430\u0435\u0442, \u043d\u0435 \u043e\u0442\u043f\u0438\u0441\u0430\u0432\u0448\u0438\u0441\u044c \u043e\u0442 \u0433\u0430\u0437\u0435\u0442\u044b, \u0442\u043e \u044d\u0442\u043e \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u0430\u0432\u0430\u0440\u0438\u0439\u043d\u043e\u043c\u0443 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044e \u0432\u0441\u0435\u0439 \u041f\u043e\u0447\u0442\u044b \u0420\u043e\u0441\u0441\u0438\u0438.<\/div>\n<\/div>\n<p>  \u0414\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043c\u0435\u0442\u043e\u0434 \u0432 <b>LibraryAPI.m<\/b>:<\/p>\n<pre><code class=\"cpp\">- (void)dealloc {     [[NSNotificationCenter defaultCenter] removeObserver:self]; } <\/code><\/pre>\n<p>  \u041a\u043e\u0433\u0434\u0430 \u043e\u0431\u044a\u0435\u043a\u0442 \u043a\u043b\u0430\u0441\u0441\u0430 \u0432\u044b\u0433\u0440\u0443\u0436\u0430\u0435\u0442\u0441\u044f \u0438\u0437 \u043f\u0430\u043c\u044f\u0442\u0438, \u043e\u043d \u043e\u0442\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043e\u0442 \u0432\u0441\u0435\u0445 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0439, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u043d \u0431\u044b\u043b \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u043d.<\/p>\n<p>  \u0418 \u0435\u0449\u0451 one more thing. \u0411\u044b\u043b\u043e \u0431\u044b \u043d\u0435\u043f\u043b\u043e\u0445\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u044b\u0435 \u043e\u0431\u043b\u043e\u0436\u043a\u0438 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0438\u0445 \u0441\u043a\u0430\u0447\u0438\u0432\u0430\u0442\u044c \u0441\u043d\u043e\u0432\u0430 \u0438 \u0441\u043d\u043e\u0432\u0430.<\/p>\n<p>  \u041e\u0442\u043a\u0440\u043e\u0439\u0442\u0435 <b>PersistencyManager.h<\/b> \u0438 \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0434\u0432\u0430 \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f\u0430 \u043c\u0435\u0442\u043e\u0434\u043e\u0432:<\/p>\n<pre><code class=\"cpp\">- (void)saveImage:(UIImage *)image filename:(NSString *)filename; - (UIImage *)getImage:(NSString *)filename; <\/code><\/pre>\n<p>  \u0418 \u0432\u043e\u0442 \u0438\u0445 \u0438\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u0432 <b>PersistencyManager.m<\/b>:<\/p>\n<pre><code class=\"cpp\">- (void)saveImage:(UIImage *)image filename:(NSString *)filename {     filename = [NSHomeDirectory() stringByAppendingFormat:@&quot;\/Documents\/%@&quot;, filename];     NSData * data = UIImagePNGRepresentation(image);     [data writeToFile:filename atomically:YES]; }  - (UIImage *)getImage:(NSString *)filename {     filename = [NSHomeDirectory() stringByAppendingFormat:@&quot;\/Documents\/%@&quot;, filename];     NSData * data = [NSData dataWithContentsOfFile:filename];     return [UIImage imageWithData:data]; } <\/code><\/pre>\n<p>  \u0412\u0440\u043e\u0434\u0435, \u0432\u0441\u0451 \u043f\u043e\u043d\u044f\u0442\u043d\u043e. \u0417\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u044b\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u044b \u0432 \u043f\u0430\u043f\u043a\u0443 <b>Documents\/<\/b> \u0432\u043d\u0443\u0442\u0440\u0438 \u043f\u0430\u043f\u043a\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. <code>getImage:<\/code> \u0432\u0435\u0440\u043d\u0451\u0442 <code>nil<\/code>, \u0435\u0441\u043b\u0438 \u0444\u0430\u0439\u043b \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d. (\u042d\u0442\u043e \u043f\u043b\u043e\u0445\u043e\u0439 \u0441\u0442\u0438\u043b\u044c, \u0441\u043e\u0432\u0435\u0442\u0443\u044e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u0443\u044e \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 \u043d\u0430 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u0430, \u0430 \u043d\u0435 \u043f\u044b\u0442\u0430\u0442\u044c\u0441\u044f \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c <code>UIImage<\/code> \u0434\u0430\u043d\u043d\u044b\u043c\u0438, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u043c\u0438 \u0438\u0437 \u043d\u0435\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0433\u043e \u0444\u0430\u0439\u043b\u0430. <i> \u2014 \u041f\u0440\u0438\u043c. \u043f\u0435\u0440.<\/i>)<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0432\u043e\u0442 \u0442\u0430\u043a\u043e\u0439 \u043c\u0435\u0442\u043e\u0434 \u0432 <b>LibraryAPI.m<\/b>:<\/p>\n<pre><code class=\"cpp\">- (void)downloadImage:(NSNotification *)notification {     \/\/ 1     NSString * coverUrl = notification.userInfo[@&quot;coverUrl&quot;];     UIImageView * imageView = notification.userInfo[@&quot;imageView&quot;];      \/\/ 2     imageView.image = [persistencyManager getImage:[coverUrl lastPathComponent]];      if (imageView.image == nil)     {     \t\/\/ 3         dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{             UIImage * image = [httpClient downloadImage:coverUrl];              \/\/ 4             dispatch_sync(dispatch_get_main_queue(), ^{                 imageView.image = image;                 [persistencyManager saveImage:image filename:[coverUrl lastPathComponent]];             });         });     } } <\/code><\/pre>\n<p>  \u0412\u043e\u0442 \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u044d\u0442\u043e\u0442 \u043a\u043e\u0434:<\/p>\n<ol>\n<li> <code>downloadImage<\/code> \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0438\u0437 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u043e\u0431\u044a\u0435\u043a\u0442 \u043e\u0431\u044a\u0435\u043a\u0442 <code>NSNotification<\/code> \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430. \u0418\u0437 \u044d\u0442\u043e\u0433\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u044e\u0442\u0441\u044f URL \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0438 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 <code>UIImageView<\/code>.<\/li>\n<li> \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0438 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u043c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0438\u0437 <code>PersistencyManager<\/code>, \u0435\u0441\u043b\u0438 \u043e\u043d\u043e \u0431\u044b\u043b\u043e \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u043e \u0440\u0430\u043d\u0435\u0435.<\/li>\n<li> \u0415\u0441\u043b\u0438 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0435\u0449\u0451 \u043d\u0435 \u0431\u044b\u043b\u043e \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u043e, \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0435\u0433\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>HTTPClient<\/code>.<\/li>\n<li> \u041a\u043e\u0433\u0434\u0430 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0430, \u043e\u0442\u043e\u0431\u0440\u0430\u0437\u0438\u043c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0432 <code>UIImageView<\/code> \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u043c \u0435\u0433\u043e \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e.<\/li>\n<\/ol>\n<p>  \u041c\u044b \u0441\u043d\u043e\u0432\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043f\u0430\u0442\u0442\u0435\u0440\u043d \u00ab\u0424\u0430\u0441\u0430\u0434\u00bb, \u0447\u0442\u043e\u0431\u044b \u0441\u043a\u0440\u044b\u0442\u044c \u043e\u0442 \u0434\u0440\u0443\u0433\u0438\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0441\u043b\u043e\u0436\u043d\u044b\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0441\u043a\u0430\u0447\u0438\u0432\u0430\u043d\u0438\u044f \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f. \u041e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u0435\u043b\u044e \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f \u043d\u0435\u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e, \u043e\u0442\u043a\u0443\u0434\u0430 \u0432\u0437\u044f\u0442\u043e \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435: \u0438\u0437 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0430 \u0438\u043b\u0438 \u0441 \u0444\u0430\u0439\u043b\u043e\u0432\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b.<\/p>\n<p>  \u041f\u043e\u0441\u0442\u0440\u043e\u0439\u0442\u0435 \u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0438 \u0443\u0432\u0438\u0434\u0438\u0442\u0435 \u043a\u0440\u0430\u0441\u0438\u0432\u044b\u0435 \u043e\u0431\u043b\u043e\u0436\u043a\u0438 \u0432 \u043d\u0430\u0448\u0435\u043c <code>HorizontalScroller<\/code>:<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage3\/be0\/acf\/0c9\/be0acf0c9869be77475ab02a5d34f192.png\"\/><\/p>\n<p>  \u041e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 \u0435\u0433\u043e \u0441\u043d\u043e\u0432\u0430. \u0417\u0430\u043c\u0435\u0442\u0438\u043c, \u043f\u0440\u0438 \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e\u043c \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u0443\u0436\u0435 \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u0437\u0430\u0434\u0435\u0440\u0436\u0435\u043a \u0432 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0435 \u043e\u0431\u043b\u043e\u0436\u043a\u0438, \u0442.\u043a. \u043e\u043d\u0438 \u0431\u044b\u043b\u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u044b \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e. \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0434\u0430\u0436\u0435 \u0431\u0435\u0437 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043a \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0443.<\/p>\n<p>  \u041d\u043e \u0432\u044b \u0437\u0430\u043c\u0435\u0442\u0438\u043b\u0438 \u0431\u0430\u0433: \u00ab\u0440\u043e\u043c\u0430\u0448\u043a\u0430\u00bb \u043d\u0435 \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u0451\u0442 \u043a\u0440\u0443\u0442\u0438\u0442\u044c\u0441\u044f! \u0412 \u0447\u0451\u043c \u0434\u0435\u043b\u043e?<\/p>\n<p>  \u0412\u0441\u0451 \u043f\u0440\u043e\u0441\u0442\u043e: \u043c\u044b \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043b\u0438 \u0438\u043d\u0434\u0438\u043a\u0430\u0442\u043e\u0440 \u043f\u0440\u0438 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f, \u043d\u043e \u0435\u0449\u0451 \u043d\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043b\u0438 \u043b\u043e\u0433\u0438\u043a\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0443\u0431\u0435\u0440\u0451\u0442 \u0438\u043d\u0434\u0438\u043a\u0430\u0442\u043e\u0440, \u043a\u043e\u0433\u0434\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u043e. \u041c\u044b \u043c\u043e\u0433\u043b\u0438 \u0431\u044b \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0435 \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437, \u043a\u043e\u0433\u0434\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u043e. \u041d\u043e \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u044d\u0442\u043e \u0431\u043e\u043b\u0435\u0435 \u043a\u0440\u0430\u0441\u0438\u0432\u044b\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c: KVO.<\/p>\n<h3>Key-Value Observing (KVO)<\/h3>\n<p>  <i>\u041e\u0442 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0447\u0438\u043a\u0430: \u043f\u043e-\u0440\u0443\u0441\u0441\u043a\u0438 \u043d\u0435 \u043d\u0430\u0448\u0451\u043b \u044d\u0442\u043e\u0439 \u0444\u0440\u0430\u0437\u044b. \u0421\u043c\u044b\u0441\u043b: \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u0435 \u0437\u0430 \u043f\u0430\u0440\u0430\u043c\u0438 \u00ab\u043a\u043b\u044e\u0447-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u00bb.<\/i><\/p>\n<p>  \u041f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u043f\u043e\u0434\u0445\u043e\u0434\u0430 KVO \u043e\u0431\u044a\u0435\u043a\u0442 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043f\u0440\u043e\u0441\u0438\u0442\u044c, \u0447\u0442\u043e\u0431\u044b \u0435\u0433\u043e \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u044f\u043b\u0438 \u043e\u0431 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f\u0445 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u2014 \u0435\u0433\u043e \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u0438\u043b\u0438 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430. \u042d\u0442\u043e\u0442 \u043f\u043e\u0434\u0445\u043e\u0434 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043e\u043f\u0438\u0441\u0430\u043d \u0432 <a href=\"https:\/\/developer.apple.com\/library\/ios\/documentation\/Cocoa\/Conceptual\/KeyValueObserving\/KeyValueObserving.html\">KVO Programming Guide<\/a> \u043e\u0442 Apple.<\/p>\n<h4>\u041a\u0430\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0430\u0442\u0442\u0435\u0440\u043d KVO<\/h4>\n<p>  KVO \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043e\u0431\u044a\u0435\u043a\u0442\u0443 \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0442\u044c \u0437\u0430 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435\u043c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430. \u0417\u0434\u0435\u0441\u044c \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c KVO, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0442\u044c \u0437\u0430 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435\u043c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 image \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043a\u043b\u0430\u0441\u0441\u0430 <code>UIImageView<\/code>.<\/p>\n<p>  \u041e\u0442\u043a\u0440\u043e\u0439\u0442\u0435 <b>AlbumView.m<\/b> \u0438 \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434 \u0432 \u043c\u0435\u0442\u043e\u0434 <code>initWithFrame:albumCover:<\/code> \u0441\u0440\u0430\u0437\u0443 \u043f\u043e\u0441\u043b\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 <code>[self addSubview:indicator];<\/code><\/p>\n<pre><code class=\"cpp\">[coverImage addObserver:self forKeyPath:@&quot;image&quot; options:0 context:nil]; <\/code><\/pre>\n<p>  \u041c\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 <code>self<\/code> (\u0441\u0430\u043c \u043e\u0431\u044a\u0435\u043a\u0442 \u043a\u043b\u0430\u0441\u0441\u0430 <code>AlbumView<\/code>) \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0442\u0435\u043b\u044f \u0437\u0430 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e\u043c <code>image<\/code> \u043e\u0431\u044a\u0435\u043a\u0442\u0430 <code>coverImage<\/code>.<br \/>  \u0418 \u043d\u0443\u0436\u043d\u043e \u00ab\u0441\u043b\u043e\u0436\u0438\u0442\u044c \u043f\u043e\u043b\u043d\u043e\u043c\u043e\u0447\u0438\u044f\u00bb \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0442\u0435\u043b\u044f, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u043c, \u0432 <b>AlbumView.m<\/b> \u043f\u0435\u0440\u0435\u0434 <code>@end<\/code>:<\/p>\n<pre><code class=\"cpp\">- (void)dealloc {     [coverImage removeObserver:self forKeyPath:@&quot;image&quot;]; } <\/code><\/pre>\n<p>  \u041d\u0430\u043a\u043e\u043d\u0435\u0446, \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043c\u0435\u0442\u043e\u0434:<\/p>\n<pre><code class=\"cpp\">- (void)observeValueForKeyPath:(NSString *)keyPath                       ofObject:(id)object                         change:(NSDictionary *)change                        context:(void *)context {     if ([keyPath isEqualToString:@&quot;image&quot;])     {         [indicator stopAnimating];     } } <\/code><\/pre>\n<p>  \u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u0432 \u043a\u0430\u0436\u0434\u043e\u043c \u043a\u043b\u0430\u0441\u0441\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0442\u0435\u043b\u0435\u043c. \u0421\u0438\u0441\u0442\u0435\u043c\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u044d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434, \u043a\u043e\u0433\u0434\u0430 \u00ab\u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0435\u043c\u043e\u0435\u00bb \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f. \u0412 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u043e\u043c \u0432\u044b\u0448\u0435 \u043a\u043e\u0434\u0435 \u043c\u044b \u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0438\u043d\u0434\u0438\u043a\u0430\u0442\u043e\u0440, \u043a\u043e\u0433\u0434\u0430 \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e <code>image<\/code>. \u0422\u043e \u0435\u0441\u0442\u044c, \u0438\u043c\u0435\u043d\u043d\u043e \u0432 \u0442\u043e\u0442 \u043c\u043e\u043c\u0435\u043d\u0442, \u043a\u043e\u0433\u0434\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u0441\u044f.<\/p>\n<p>  (\u0422\u043e\u0436\u0435 \u043f\u043b\u043e\u0445\u0430\u044f \u0440\u0430\u0441\u0448\u0438\u0440\u044f\u0435\u043c\u043e\u0441\u0442\u044c, \u044f \u0431\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u043b \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 <code>change<\/code>, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0435\u0441\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e\u0431 \u0438\u0437\u043c\u0435\u043d\u0451\u043d\u043d\u043e\u043c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0435. \u0412 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438, \u0442\u0430\u043c \u0435\u0441\u0442\u044c \u0441\u0442\u0430\u0440\u043e\u0435 \u0438 \u043d\u043e\u0432\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430. \u0415\u0441\u043b\u0438 \u0441\u0442\u0430\u0440\u043e\u0435 \u0431\u044b\u043b\u043e <code>nil<\/code>, \u0430 \u043d\u043e\u0432\u043e\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0443 =&gt; \u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0440\u043e\u043c\u0430\u0448\u043a\u0443.<i> \u2014 \u041f\u0440\u0438\u043c. \u043f\u0435\u0440.<\/i>)<\/p>\n<p>  \u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435. \u0418\u043d\u0434\u0438\u043a\u0430\u0442\u043e\u0440 \u0434\u043e\u043b\u0436\u0435\u043d \u0438\u0441\u0447\u0435\u0437\u043d\u0443\u0442\u044c:<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage3\/7a1\/de1\/2da\/7a1de12da283036e6803be36a7faffb9.png\"\/><\/p>\n<p>  <b>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435.<\/b> \u0412\u0441\u0435\u0433\u0434\u0430 \u0443\u0434\u0430\u043b\u044f\u0439\u0442\u0435 \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0442\u0435\u043b\u0435\u0439 \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 <code>dealloc<\/code>. \u0418\u043d\u0430\u0447\u0435 \u0432\u0430\u0448\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0443\u043f\u0430\u0434\u0451\u0442, \u043a\u043e\u0433\u0434\u0430 \u043f\u043e\u043f\u044b\u0442\u0430\u0435\u0442\u0441\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043d\u0435\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u043c\u0443 \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0442\u0435\u043b\u044e!<\/p>\n<p>  \u0415\u0441\u043b\u0438 \u0432\u044b \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u043e\u0438\u0433\u0440\u0430\u0435\u0442\u0435\u0441\u044c \u0441 \u0432\u0430\u0448\u0438\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u043c \u0438 \u0437\u0430\u043a\u0440\u043e\u0435\u0442\u0435 \u0435\u0433\u043e, \u0430 \u043f\u043e\u0442\u043e\u043c \u0441\u043d\u043e\u0432\u0430 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435, \u0442\u043e \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435: \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f (\u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u044b\u0439 \u0430\u043b\u044c\u0431\u043e\u043c) \u043d\u0435 \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435. \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u0441 \u0447\u0435\u0433\u043e \u0431\u044b? \ud83d\ude42<\/p>\n<p>  \u0427\u0442\u043e\u0431\u044b \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u044d\u0442\u0443 \u00ab\u043e\u043f\u043b\u043e\u0448\u043d\u043e\u0441\u0442\u044c\u00bb, \u043c\u044b \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043a \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c\u0443 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0443 \u043f\u043e \u0441\u043f\u0438\u0441\u043a\u0443:<\/p>\n<h2>\u0425\u0440\u0430\u043d\u0438\u0442\u0435\u043b\u044c (Memento)<\/h2>\n<p>  \u00ab\u0425\u0440\u0430\u043d\u0438\u0442\u0435\u043b\u044c\u00bb \u0444\u0438\u043a\u0441\u0438\u0440\u0443\u0435\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442 \u0435\u0433\u043e\u2026 \u0433\u0434\u0435-\u0442\u043e. \u0414\u0430\u043b\u044c\u0448\u0435 \u044d\u0442\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u0451\u043d\u043d\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043e \u0431\u0435\u0437 \u043d\u0430\u0440\u0443\u0448\u0435\u043d\u0438\u044f \u0438\u043d\u043a\u0430\u043f\u0441\u0443\u043b\u044f\u0446\u0438\u0438, \u0442.\u0435. \u0437\u0430\u043a\u0440\u044b\u0442\u044b\u0435 (private) \u0447\u043b\u0435\u043d\u044b \u043a\u043b\u0430\u0441\u0441\u0430 \u043e\u0441\u0442\u0430\u044e\u0442\u0441\u044f \u0437\u0430\u043a\u0440\u044b\u0442\u044b\u043c\u0438.<\/p>\n<h3>\u041a\u0430\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0448\u0430\u0431\u043b\u043e\u043d Memento<\/h3>\n<p>  \u0414\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0434\u0432\u0430 \u043c\u0435\u0442\u043e\u0434\u0430 \u0432 <b>ViewController.m<\/b>:<\/p>\n<pre><code class=\"cpp\">- (void)saveCurrentState {     \/\/ \u041a\u043e\u0433\u0434\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u0435\u0442 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0438 \u043f\u043e\u0442\u043e\u043c \u0441\u043d\u043e\u0432\u0430 \u043a \u043d\u0430\u043c \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442,     \/\/ \u043e\u043d \u0445\u043e\u0447\u0435\u0442 \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0442\u043e \u0436\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043e\u043d \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u043b. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e     \/\/ \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u044b\u0439 \u0430\u043b\u044c\u0431\u043e\u043c. \u0417\u0434\u0435\u0441\u044c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438,     \/\/ \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c NSUserDefaults:     [[NSUserDefaults standardUserDefaults] setInteger:currentAlbumIndex                                                forKey:@&quot;currentAlbumIndex&quot;]; }  - (void)loadPreviousState {     currentAlbumIndex = [[NSUserDefaults standardUserDefaults] integerForKey:@&quot;currentAlbumIndex&quot;];     [self showDataForAlbumAtIndex:currentAlbumIndex]; } <\/code><\/pre>\n<p>  \u041c\u0435\u0442\u043e\u0434 <code>saveCurrentState<\/code> \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442 \u0438\u043d\u0434\u0435\u043a\u0441 \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u0430\u043b\u044c\u0431\u043e\u043c\u0430. <code>NSUserDefaults<\/code> \u2014 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a \u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c\u043e\u0435 iOS.<\/p>\n<p>  <code>loadPreviousState<\/code> \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u0442 \u0438 \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u0438\u043d\u0434\u0435\u043a\u0441, \u0441\u043e\u0445\u0440\u0430\u043d\u0451\u043d\u043d\u044b\u0439 \u0440\u0430\u043d\u0435\u0435. \u042d\u0442\u043e \u043d\u0435 \u0441\u043e\u0432\u0441\u0435\u043c \u043f\u043e\u043b\u043d\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0430 \u00ab\u0425\u0440\u0430\u043d\u0438\u0442\u0435\u043b\u044c\u00bb, \u043d\u043e \u043c\u044b \u043a \u043d\u0435\u0439 \u0438\u0434\u0451\u043c.<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443 \u0432 <b>ViewController.m<\/b> \u043a \u043c\u0435\u0442\u043e\u0434\u0443 <code>viewDidLoad<\/code> \u043f\u0435\u0440\u0435\u0434 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0435\u0439 \u0441\u043a\u0440\u043e\u043b\u043b\u0435\u0440\u0430:<\/p>\n<pre><code class=\"cpp\">[self loadPreviousState]; <\/code><\/pre>\n<p>  \u042d\u0442\u043e\u0442 \u0432\u044b\u0437\u043e\u0432 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u0442 \u0440\u0430\u043d\u0435\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u043d\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u041a\u0430\u043a \u043d\u0430\u043c \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0442\u0435\u043a\u0443\u0449\u0435\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f? \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0439. iOS \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0435 <code>UIApplicationDidEnterBackgroundNotification<\/code>, \u043a\u043e\u0433\u0434\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0443\u0445\u043e\u0434\u0438\u0442 \u0432 \u0444\u043e\u043d. \u041a\u043e\u0433\u0434\u0430 \u043d\u0430\u043c \u043f\u0440\u0438\u0434\u0451\u0442 \u044d\u0442\u043e \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0435, \u0432\u044b\u0437\u043e\u0432\u0435\u043c <code>saveCurrentState<\/code>. \u0423\u0434\u043e\u0431\u043d\u043e? \u0414\u0430.<\/p>\n<p>  \u0414\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443 \u0432 \u043a\u043e\u043d\u0435\u0446 \u043c\u0435\u0442\u043e\u0434\u0430 <code>viewDidLoad<\/code>:<\/p>\n<pre><code class=\"cpp\">[[NSNotificationCenter defaultCenter] addObserver:self                                          selector:@selector(saveCurrentState)                                              name:UIApplicationDidEnterBackgroundNotification                                            object:nil]; <\/code><\/pre>\n<p>  \u041a\u043e\u0433\u0434\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0441\u043e\u0431\u0435\u0440\u0451\u0442\u0441\u044f \u0443\u0439\u0442\u0438 \u0432 \u0444\u043e\u043d\u043e\u0432\u044b\u0439 \u0440\u0435\u0436\u0438\u043c, <code>ViewController<\/code> \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442 \u0442\u0435\u043a\u0443\u0449\u0435\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435, \u0432\u044b\u0437\u0432\u0430\u0432 <code>saveCurrentState<\/code>.<\/p>\n<p>  <i>\u041e\u0442 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0447\u0438\u043a\u0430:<\/i> \u042d\u0442\u043e\u0442 \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b \u043d\u0430\u043f\u0438\u0441\u0430\u043d \u0434\u043b\u044f iOS 6, \u0433\u0434\u0435 \u043d\u0435\u043b\u044c\u0437\u044f \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u0437\u044f\u0442\u044c \u0438 \u0437\u0430\u043a\u0440\u044b\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435. \u041c\u043e\u0436\u043d\u043e <b>\u0442\u043e\u043b\u044c\u043a\u043e<\/b> \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0432 \u0444\u043e\u043d, \u0430 \u0437\u0430\u0442\u0435\u043c \u0437\u0430\u043a\u0440\u044b\u0442\u044c. \u041d\u043e \u0447\u0442\u043e \u0435\u0441\u043b\u0438 Apple \u0440\u0430\u0437\u0440\u0435\u0448\u0438\u0442 \u0441\u0440\u0430\u0437\u0443 \u0437\u0430\u043a\u0440\u044b\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435? \u0422\u043e\u0433\u0434\u0430 \u0432\u0430\u0448\u0430 \u043b\u043e\u0433\u0438\u043a\u0430 \u0441\u043b\u043e\u043c\u0430\u0435\u0442\u0441\u044f? \u041b\u0443\u0447\u0448\u0435 \u0434\u0443\u043c\u0430\u0442\u044c \u043e\u0431 \u044d\u0442\u043e\u043c \u0437\u0430\u0440\u0430\u043d\u0435\u0435, \u0430 \u043d\u0435 \u043f\u043e\u0441\u043b\u0435 \u0432\u044b\u0445\u043e\u0434\u0430 iOS 7. \u041a \u0441\u0447\u0430\u0441\u0442\u044c\u044e, \u0432 \u041a\u0443\u043f\u0435\u0440\u0442\u0438\u043d\u043e \u043f\u043e\u0436\u0430\u043b\u0435\u043b\u0438 \u0442\u0430\u043a\u0438\u0445 \u0433\u043e\u0440\u0435-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u043d\u0435 \u043d\u0430 \u0437\u0434\u0440\u0430\u0432\u044b\u0439 \u0441\u043c\u044b\u0441\u043b, \u0430 \u043d\u0430 \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u044e\u0437\u0430\u0431\u0438\u043b\u0438\u0442\u0438. \u0412\u043e\u043f\u0440\u0435\u043a\u0438 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438, iOS 7.0 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0435 \u2026DidEnterBackground\u2026, \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u0432\u044b \u043d\u0435 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0435 \u0432 \u0444\u043e\u043d, \u0430 \u0441\u0440\u0430\u0437\u0443 \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u0435\u0442\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435. \u041d\u043e \u0432\u043e\u043e\u0431\u0449\u0435, \u043d\u0435 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043e\u0436\u0438\u0434\u0430\u0442\u044c \u043e\u0442 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 \u041e\u0421 \u0442\u0430\u043a\u043e\u0439 \u043e\u0442\u0437\u044b\u0432\u0447\u0438\u0432\u043e\u0441\u0442\u0438.<\/p>\n<p>  \u0421\u0440\u0430\u0437\u0443 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434:<\/p>\n<pre><code class=\"cpp\">- (void)dealloc {     [[NSNotificationCenter defaultCenter] removeObserver:self]; } <\/code><\/pre>\n<p>  \u0423\u0434\u0430\u043b\u0438\u043b\u0438 \u043e\u0431\u044a\u0435\u043a\u0442 <code>ViewController<\/code> \u0438\u0437 \u0447\u0438\u0441\u043b\u0430 \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0442\u0435\u043b\u0435\u0439, \u043f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u0432\u044b\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u0435\u0433\u043e \u0438\u0437 \u043f\u0430\u043c\u044f\u0442\u0438.<\/p>\n<p>  \u0421\u043d\u043e\u0432\u0430 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u043f\u0435\u0440\u0435\u0439\u0434\u0438\u0442\u0435 \u043a \u043e\u0434\u043d\u043e\u043c\u0443 \u0438\u0437 \u0430\u043b\u044c\u0431\u043e\u043c\u043e\u0432. \u0417\u0430\u0442\u0435\u043c \u0437\u0430\u043a\u0440\u043e\u0439\u0442\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0434\u0432\u0430\u0436\u0434\u044b \u043d\u0430\u0436\u0430\u0432 \u043a\u043d\u043e\u043f\u043a\u0443 Home (\u0432 \u0441\u0438\u043c\u0443\u043b\u044f\u0442\u043e\u0440\u0435 \u2014 <b>\u2318\u21e7H<\/b>) \u0438 \u0443\u0434\u0430\u043b\u0438\u0442\u0435 \u0435\u0433\u043e \u0438\u0437 \u043c\u043d\u043e\u0433\u043e\u0437\u0430\u0434\u0430\u0447\u043d\u043e\u0441\u0442\u0438. \u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 \u0437\u0430\u043d\u043e\u0432\u043e \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044c\u0442\u0435, \u0447\u0442\u043e \u0432\u044b\u0431\u0440\u0430\u043d \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u043e\u0442 \u0430\u043b\u044c\u0431\u043e\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u044b\u043b \u0432\u044b\u0431\u0440\u0430\u043d \u0434\u043e \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u043a\u0430:<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage3\/e6f\/099\/dd0\/e6f099dd0623d6e854e57d429f67f5b5.png\"\/><\/p>\n<p>  \u0421\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u043e\u0431 \u0430\u043b\u044c\u0431\u043e\u043c\u0435 \u0432 <code>TableView<\/code> \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u044b, \u043d\u043e \u0432 \u0441\u043a\u0440\u043e\u043b\u043b\u0435\u0440\u0435 \u043e\u0431\u043b\u043e\u0436\u043a\u0430 \u0432\u044b\u0431\u0440\u0430\u043d\u0430 \u0434\u0440\u0443\u0433\u0430\u044f. \u041f\u043e\u0447\u0435\u043c\u0443?<\/p>\n<p>  \u0410 \u0432\u043e\u0442 \u0442\u0443\u0442 \u043d\u0430\u043c \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434 <code>initialViewIndexForHorizontalScroller:<\/code> \u2014 \u043e\u043f\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430. \u041f\u043e\u043a\u0430 \u043e\u043d \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d \u0432 \u0434\u0435\u043b\u0435\u0433\u0430\u0442\u0435 (\u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 <code>ViewController<\/code> \u0434\u0435\u043b\u0435\u0433\u0430\u0442). \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441\u043a\u0440\u043e\u043b\u043b\u0435\u0440 \u043f\u0440\u0438 \u0441\u0442\u0430\u0440\u0442\u0435 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u043d\u043e\u043b\u044c.<\/p>\n<p>  \u0427\u0442\u043e\u0431\u044b \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u044d\u0442\u043e, \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u043c\u0435\u0442\u043e\u0434 \u0432 <b>ViewController.m<\/b>:<\/p>\n<pre><code class=\"cpp\">- (NSInteger)initialViewIndexForHorizontalScroller:(HorizontalScroller *)scroller {     return currentAlbumIndex; } <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0438\u043d\u0434\u0435\u043a\u0441 \u0441\u043a\u0440\u043e\u043b\u043b\u0435\u0440\u0430 (\u043d\u043e\u043c\u0435\u0440 \u0430\u043b\u044c\u0431\u043e\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e \u0446\u0435\u043d\u0442\u0440\u0443) \u0431\u0443\u0434\u0435\u0442 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d \u043d\u0430 <code>currentAlbumIndex<\/code>. \u041e\u0442\u043b\u0438\u0447\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0431\u043e\u043b\u0435\u0435 \u043f\u0435\u0440\u0441\u043e\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c.<\/p>\n<p>  \u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0441\u043d\u043e\u0432\u0430. \u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0440\u0435\u0448\u0435\u043d\u0430!<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage3\/fef\/470\/9d6\/fef4709d6288753e28a9e3a5e8951922.png\"\/><\/p>\n<p>  \u0415\u0441\u043b\u0438 \u0432\u044b \u043d\u0430\u0439\u0434\u0451\u0442\u0435 \u0432 \u043a\u043b\u0430\u0441\u0441\u0435 <code>PersistencyManager<\/code> \u043c\u0435\u0442\u043e\u0434 <code>init<\/code>, \u0442\u043e \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u0430 <code>Album<\/code> \u0436\u0435\u0441\u0442\u043a\u043e \u043f\u0440\u043e\u043f\u0438\u0441\u0430\u043d\u044b \u0432 \u043a\u043e\u0434\u0435. \u0422\u043e \u0435\u0441\u0442\u044c, \u044d\u0442\u043e\u0442 \u043a\u043e\u0434 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 <code>PersistencyManager<\/code>. \u041d\u043e \u043b\u0443\u0447\u0448\u0435 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0430\u043b\u044c\u0431\u043e\u043c\u043e\u0432 \u043e\u0434\u0438\u043d \u0440\u0430\u0437 \u0438 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0438\u0445 \u0432 \u0444\u0430\u0439\u043b\u0435. \u041a\u0430\u043a \u043c\u044b \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u0430\u043b\u044c\u0431\u043e\u043c\u0430 \u0432 \u0444\u0430\u0439\u043b?<\/p>\n<p>  \u041e\u0434\u0438\u043d \u0438\u0437 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432 \u2014 \u0432\u0440\u0443\u0447\u043d\u0443\u044e \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0438\u0442\u044c \u0432\u0441\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0430\u043b\u044c\u0431\u043e\u043c\u0430, \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c \u0438\u0445 \u0432 \u0444\u0430\u0439\u043b plist, \u0430 \u0437\u0430\u0442\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0438\u0437 \u043d\u0438\u0445 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u044b \u043a\u043b\u0430\u0441\u0441\u0430 <code>Album<\/code> \u043f\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438. \u042d\u0442\u043e \u043d\u0435 \u043b\u0443\u0447\u0448\u0438\u0439 \u0441\u043f\u043e\u0441\u043e\u0431, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e:  <\/p>\n<ol>\n<li>\u041f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u044f\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0441\u0432\u043e\u0439\u0441\u0442\u0432 \u043f\u0440\u044f\u043c\u043e \u0432 \u043a\u043e\u0434\u0435. \u0415\u0441\u043b\u0438 \u043f\u043e\u0437\u0436\u0435 \u0432\u044b \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u0442\u0435 \u043a\u043b\u0430\u0441\u0441 Movie \u0441 \u0434\u0440\u0443\u0433\u0438\u043c \u043d\u0430\u0431\u043e\u0440\u043e\u043c \u0441\u0432\u043e\u0439\u0441\u0442\u0432, \u0434\u043b\u044f \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0438 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u044d\u0442\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043d\u043e\u0432\u044b\u0439 \u043a\u043e\u0434.<\/li>\n<li>\u041c\u044b \u043d\u0435 \u0441\u043c\u043e\u0436\u0435\u043c \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0437\u0430\u043a\u0440\u044b\u0442\u044b\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445, \u0442\u0430\u043a \u043a\u0430\u043a \u043e\u043d\u0438 \u043d\u0435\u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u0434\u043b\u044f \u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0435\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430.<\/li>\n<\/ol>\n<p>  \u0412\u043e\u0442 \u043f\u043e\u0447\u0435\u043c\u0443 Apple \u043f\u0440\u0438\u0434\u0443\u043c\u0430\u043b\u0438<sup>[citation needed]<\/sup> \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u0430\u0440\u0445\u0438\u0432\u0430\u0446\u0438\u0438.<\/p>\n<h2>\u0410\u0440\u0445\u0438\u0432\u0430\u0446\u0438\u044f<\/h2>\n<p>  \u041e\u0434\u043d\u0430 \u0438\u0437 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0439 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0430 \u00ab\u0425\u0440\u0430\u043d\u0438\u0442\u0435\u043b\u044c\u00bb \u043e\u0442 Apple \u2014 \u044d\u0442\u043e \u0430\u0440\u0445\u0438\u0432\u0430\u0446\u0438\u044f. \u041e\u043d\u0430 \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043e\u0431\u044a\u0435\u043a\u0442 \u0432 \u043f\u043e\u0442\u043e\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0438 \u043f\u043e\u0437\u0436\u0435 \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0431\u0435\u0437 \u043d\u0430\u0440\u0443\u0448\u0435\u043d\u0438\u044f \u0438\u043d\u043a\u0430\u043f\u0441\u0443\u043b\u044f\u0446\u0438\u0438, \u0442.\u0435. \u043d\u0435 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u044f \u0437\u0430\u043a\u0440\u044b\u0442\u044b\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0432\u043d\u0435\u0448\u043d\u0438\u043c \u043a\u043b\u0430\u0441\u0441\u0430\u043c. \u0414\u043b\u044f \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u0430\u0432\u0442\u043e\u0440 \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b\u0430 \u043e\u0442\u0441\u044b\u043b\u0430\u0435\u0442 \u043d\u0430\u0441 \u043a <a href=\"http:\/\/www.raywenderlich.com\/store\/ios-6-by-tutorials\">\u043a\u043d\u0438\u0433\u0435<\/a> \u043e\u0442 \u043a\u043e\u043c\u0430\u043d\u0434\u044b Ray Wenderlich \u0438\u043b\u0438 \u043e\u043f\u044f\u0442\u044c \u0436\u0435 \u043a <a href=\"https:\/\/developer.apple.com\/library\/ios\/documentation\/Cocoa\/Conceptual\/Archiving\/Archiving.html\">\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 Apple<\/a>.<\/p>\n<h3>\u041a\u0430\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0430\u0440\u0445\u0438\u0432\u0430\u0446\u0438\u044e<\/h3>\n<p>  \u0421\u043f\u0435\u0440\u0432\u0430 \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u043e\u0431\u044a\u044f\u0432\u0438\u0442\u044c, \u0447\u0442\u043e \u043a\u043b\u0430\u0441\u0441 <code>Album<\/code> \u043c\u043e\u0436\u043d\u043e \u0430\u0440\u0445\u0438\u0432\u0438\u0440\u043e\u0432\u0430\u0442\u044c. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u0434\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u043e\u043d \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b <code>NSCoding<\/code>. \u041e\u0442\u043a\u0440\u043e\u0439\u0442\u0435 <b>Album.h<\/b> \u0438 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u0435 \u0441\u0442\u0440\u043e\u0447\u043a\u0443 <code>@interface<\/code> \u043d\u0430 \u044d\u0442\u0443:<\/p>\n<pre><code class=\"cpp\">@interface Album : NSObject &lt;NSCoding&gt; <\/code><\/pre>\n<p>  \u0414\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0434\u0432\u0430 \u043c\u0435\u0442\u043e\u0434\u0430 \u0432 <b>Album.m<\/b>:<\/p>\n<pre><code class=\"cpp\">- (void)encodeWithCoder:(NSCoder *)aCoder {     [aCoder encodeObject:self.year forKey:@&quot;year&quot;];     [aCoder encodeObject:self.title forKey:@&quot;album&quot;];     [aCoder encodeObject:self.artist forKey:@&quot;artist&quot;];     [aCoder encodeObject:self.coverUrl forKey:@&quot;cover_url&quot;];     [aCoder encodeObject:self.genre forKey:@&quot;genre&quot;]; }  - (id)initWithCoder:(NSCoder *)aDecoder {     self = [super init];     if (self)     {         _year = [aDecoder decodeObjectForKey:@&quot;year&quot;];         _title = [aDecoder decodeObjectForKey:@&quot;album&quot;];         _artist = [aDecoder decodeObjectForKey:@&quot;artist&quot;];         _coverUrl = [aDecoder decodeObjectForKey:@&quot;cover_url&quot;];         _genre = [aDecoder decodeObjectForKey:@&quot;genre&quot;];     }     return self; } <\/code><\/pre>\n<p>  \u0427\u0442\u043e\u0431\u044b \u0430\u0440\u0445\u0438\u0432\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043a\u043b\u0430\u0441\u0441\u0430, \u043c\u044b \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c <code>encodeWithCoder:<\/code>. \u0410 \u043c\u0435\u0442\u043e\u0434 <code>initWithCoder:<\/code> \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u0430\u043b\u044c\u0431\u043e\u043c\u0430 \u0438\u0437 \u0430\u0440\u0445\u0438\u0432\u0430. \u041f\u0440\u043e\u0441\u0442\u043e\u0439, \u043d\u043e \u043c\u043e\u0449\u043d\u044b\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442.<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c, \u043a\u043e\u0433\u0434\u0430 \u043a\u043b\u0430\u0441\u0441 <code>Album<\/code> \u043c\u043e\u0436\u043d\u043e \u0430\u0440\u0445\u0438\u0432\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u043a\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435\/\u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0443 \u0441\u043f\u0438\u0441\u043a\u0430 \u0430\u043b\u044c\u0431\u043e\u043c\u043e\u0432.<\/p>\n<p>  \u0414\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f \u043c\u0435\u0442\u043e\u0434\u0430 \u0432 <b>PersistencyManager.h<\/b>:<\/p>\n<pre><code class=\"cpp\">- (void)saveAlbums; <\/code><\/pre>\n<p>  \u0418 \u0435\u0433\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0432 <b>PersistencyManager.m<\/b>:<\/p>\n<pre><code class=\"cpp\">- (void)saveAlbums {     NSString * filename = [NSHomeDirectory() stringByAppendingString:@&quot;\/Documents\/albums.bin&quot;];     NSData * data = [NSKeyedArchiver archivedDataWithRootObject:albums];     [data writeToFile:filename atomically:YES]; } <\/code><\/pre>\n<p>  <code>NSKeyedArchiver<\/code> \u0430\u0440\u0445\u0438\u0432\u0438\u0440\u0443\u0435\u0442 \u043c\u0430\u0441\u0441\u0438\u0432 \u0430\u043b\u044c\u0431\u043e\u043c\u043e\u0432 \u0432 \u0444\u0430\u0439\u043b &quot;<code>albums.bin<\/code>&quot;.<\/p>\n<p>  \u041a\u043e\u0433\u0434\u0430 \u043c\u044b \u0430\u0440\u0445\u0438\u0432\u0438\u0440\u0443\u0435\u043c \u043e\u0431\u044a\u0435\u043a\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0434\u0440\u0443\u0433\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b, \u0430\u0440\u0445\u0438\u0432\u0430\u0442\u043e\u0440 \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u043e \u0430\u0440\u0445\u0438\u0432\u0438\u0440\u0443\u0435\u0442 \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b. \u0423 \u043d\u0430\u0441 \u0430\u0440\u0445\u0438\u0432\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0441 <code>albums<\/code> (\u043c\u0430\u0441\u0441\u0438\u0432 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 <code>Album<\/code>). \u0422\u0430\u043a \u043a\u0430\u043a \u043e\u0431\u0430 \u043a\u043b\u0430\u0441\u0441\u0430 <code>NSArray<\/code> \u0438 <code>Album<\/code> \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0442 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 <code>NSCoding<\/code>, \u0432\u0441\u0451 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u043e \u0430\u0440\u0445\u0438\u0432\u0438\u0440\u0443\u0435\u0442\u0441\u044f.<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0432 <b>PersistencyManager.m<\/b> \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u0435 \u043c\u0435\u0442\u043e\u0434 <code>init<\/code> \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434:<\/p>\n<pre><code class=\"cpp\">- (id)init {     self = [super init];     if (self)     {         NSData * data = [NSData dataWithContentsOfFile:[NSHomeDirectory() stringByAppendingString:@&quot;\/Documents\/albums.bin&quot;]];         albums = [NSKeyedUnarchiver unarchiveObjectWithData:data];         if (albums == nil)         {             albums = [NSMutableArray arrayWithArray:                   @[[[Album alloc] initWithTitle:@&quot;Best of Bowie&quot;                                           artist:@&quot;David Bowie&quot;                                         coverUrl:@&quot;http:\/\/www.coversproject.com\/static\/thumbs\/album\/album_david%20bowie_best%20of%20bowie.png&quot;                                             year:@&quot;1992&quot;],                      [[Album alloc] initWithTitle:@&quot;It's My Life&quot;                                           artist:@&quot;No Doubt&quot;                                         coverUrl:@&quot;http:\/\/www.coversproject.com\/static\/thumbs\/album\/album_no%20doubt_its%20my%20life%20%20bathwater.png&quot;                                             year:@&quot;2003&quot;],                      [[Album alloc] initWithTitle:@&quot;Nothing Like The Sun&quot;                                           artist:@&quot;Sting&quot;                                         coverUrl:@&quot;http:\/\/www.coversproject.com\/static\/thumbs\/album\/album_sting_nothing%20like%20the%20sun.png&quot;                                             year:@&quot;1999&quot;],                      [[Album alloc] initWithTitle:@&quot;Staring at the Sun&quot;                                           artist:@&quot;U2&quot;                                         coverUrl:@&quot;http:\/\/www.coversproject.com\/static\/thumbs\/album\/album_u2_staring%20at%20the%20sun.png&quot;                                             year:@&quot;2000&quot;],                      [[Album alloc] initWithTitle:@&quot;American Pie&quot;                                           artist:@&quot;Madonna&quot;                                         coverUrl:@&quot;http:\/\/www.coversproject.com\/static\/thumbs\/album\/album_madonna_american%20pie.png&quot;                                             year:@&quot;2000&quot;]]];             [self saveAlbums];         }     }     return self; } <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c <code>NSKeyedUnarchiver<\/code> \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u0430\u043b\u044c\u0431\u043e\u043c\u0430 \u0438\u0437 \u0444\u0430\u0439\u043b\u0430, \u0435\u0441\u043b\u0438 \u043e\u043d \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442. \u0415\u0441\u043b\u0438 \u043d\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442, \u0442\u043e \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0451\u043c \u0430\u043b\u044c\u0431\u043e\u043c\u044b \u0438\u0437 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445. \u0418 \u0441\u0440\u0430\u0437\u0443 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0438\u0445 \u043f\u0440\u0438 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u0437\u0430\u043f\u0443\u0441\u043a\u0435.<\/p>\n<p>  \u0422\u0430\u043a\u0436\u0435 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0430\u043b\u044c\u0431\u043e\u043c\u0430 \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437, \u043a\u043e\u0433\u0434\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0443\u0445\u043e\u0434\u0438\u0442 \u0432 \u0444\u043e\u043d. \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u044d\u0442\u043e \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0441\u0435\u0439\u0447\u0430\u0441, \u043d\u043e \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u0432\u044b \u0437\u0430\u0445\u043e\u0442\u0438\u0442\u0435 \u043f\u043e\u0437\u0436\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0430\u043b\u044c\u0431\u043e\u043c\u0430? \u0422\u043e\u0433\u0434\u0430 \u043d\u0443\u0436\u043d\u043e \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u0432\u0441\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u044e\u0442\u0441\u044f.<\/p>\n<p>  \u0414\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u043d\u043e\u0432\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 \u0432 <b>LibraryAPI.h<\/b>:<\/p>\n<pre><code class=\"cpp\">- (void)saveAlbums; <\/code><\/pre>\n<p>  \u0418\u043c\u0435\u043d\u043d\u043e \u043a <code>LibraryAPI<\/code>, \u043a\u0430\u043a \u043c\u044b \u043f\u043e\u043c\u043d\u0438\u043c, \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043e\u0431\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u0437\u0430 \u0441\u0435\u0440\u0432\u0438\u0441\u0430\u043c\u0438. \u0418\u043c\u0435\u043d\u043d\u043e \u0437\u0434\u0435\u0441\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0443\u043a\u0430\u0436\u0435\u0442 <code>PersistencyManager<\/code>&#8216;\u0443, \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0430\u043b\u044c\u0431\u043e\u043c\u0430.<\/p>\n<p>  \u0418 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 \u0432 <b>LibraryAPI.m<\/b>:<\/p>\n<pre><code class=\"cpp\">- (void)saveAlbums {     [persistencyManager saveAlbums]; } <\/code><\/pre>\n<p>  \u041d\u0430\u043a\u043e\u043d\u0435\u0446, \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434 \u0432 <b>ViewController.m<\/b> \u0432 \u043a\u043e\u043d\u0435\u0446 \u043c\u0435\u0442\u043e\u0434\u0430 <code>saveCurrentState<\/code>:<\/p>\n<pre><code class=\"cpp\">[[LibraryAPI sharedInstance] saveAlbums]; <\/code><\/pre>\n<p>  \u041c\u044b \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0430\u043b\u044c\u0431\u043e\u043c\u043e\u0432 \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437, \u043a\u043e\u0433\u0434\u0430 <code>ViewController<\/code> \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442 \u0441\u0432\u043e\u0451 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435.<\/p>\n<p>  \u0412\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u0435 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f (Build), \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c, \u0447\u0442\u043e \u0432\u0441\u0451 \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u0442\u0441\u044f.<\/p>\n<p>  \u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u043d\u0435\u0442 \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u0441\u043f\u043e\u0441\u043e\u0431\u0430 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0441\u0442\u044c \u0441\u043e\u0445\u0440\u0430\u043d\u0451\u043d\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445. \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043d\u0430\u0439\u0442\u0438 \u043f\u0430\u043f\u043a\u0443 <code>Documents<\/code> \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0432 \u0441\u0438\u043c\u0443\u043b\u044f\u0442\u043e\u0440\u0435 (\u043b\u0438\u0431\u043e \u043d\u0430 \u0434\u0435\u0432\u0430\u0439\u0441\u0435 \u0447\u0435\u0440\u0435\u0437 iExplorer). \u0422\u0430\u043c \u043c\u044b \u0443\u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u0444\u0430\u0439\u043b \u0430\u043b\u044c\u0431\u043e\u043c\u043e\u0432 \u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0441\u044f. \u041d\u043e \u0447\u0442\u043e\u0431\u044b \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u043b\u044e\u0431\u044b\u0435 \u0434\u0440\u0443\u0433\u0438\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f, \u043d\u0430\u043c \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b \u043f\u043e \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>  \u041d\u043e \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0443 \u043d\u0430\u0441 \u0438 \u0442\u0430\u043a \u043e\u0434\u0438\u043d \u0438\u0437 \u0441\u0430\u043c\u044b\u0445 \u0434\u043b\u0438\u043d\u043d\u044b\u0445 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u043e\u0432 \u043d\u0430 \u0445\u0430\u0431\u0440\u0435, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u043f\u0440\u043e\u0449\u0435: \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u0430\u043b\u044c\u0431\u043e\u043c <s>\u0434\u043b\u044f \u043f\u0440\u043e\u0442\u0438\u0432\u043d\u0438\u043a\u043e\u0432 \u043f\u043e\u043f\u0441\u044b<\/s>. \u0418 \u0437\u0430\u043e\u0434\u043d\u043e \u043f\u0440\u043e\u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u043c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043e\u0442\u043c\u0435\u043d\u0438\u0442\u044c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435, \u0435\u0441\u043b\u0438 \u0432\u0434\u0440\u0443\u0433 \u043c\u044b \u0443\u0434\u0430\u043b\u0438\u043b\u0438 \u0430\u043b\u044c\u0431\u043e\u043c \u043f\u043e \u043e\u0448\u0438\u0431\u043a\u0435.<\/p>\n<p>  \u0414\u043b\u044f \u043d\u0430\u0441 \u044d\u0442\u043e \u043e\u0442\u043b\u0438\u0447\u043d\u0430\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u0442\u044c \u043e \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u043c \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0435 \u0432 \u0441\u043f\u0438\u0441\u043a\u0435: \u041a\u043e\u043c\u0430\u043d\u0434\u0430.<\/p>\n<h2>\u041a\u043e\u043c\u0430\u043d\u0434\u0430<\/h2>\n<p>  <i>\u041a\u043e\u043c\u0430\u043d\u0434\u0430 \u2014 \u0432 \u0441\u043c\u044b\u0441\u043b\u0435 \u00ab\u043f\u0440\u0438\u043a\u0430\u0437\u00bb, Command, \u0430 \u043d\u0435 Team.<\/i><\/p>\n<p>  \u041f\u0430\u0442\u0442\u0435\u0440\u043d \u00ab\u041a\u043e\u043c\u0430\u043d\u0434\u0430\u00bb \u0438\u043d\u043a\u0430\u043f\u0441\u0443\u043b\u0438\u0440\u0443\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441 \u0438\u043b\u0438 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0432 \u043e\u0431\u044a\u0435\u043a\u0442. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u0430 <b>\u00ab\u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u00bb<\/b>:<\/p>\n<pre><code class=\"cpp\">Forrest-&gt;Run(speed, distance); <\/code><\/pre>\n<p>  \u0418\u0437 \u044d\u0442\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0451\u043c \u043e\u0431\u044a\u0435\u043a\u0442 \u0441 \u0442\u0440\u0435\u043c\u044f \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430\u043c\u0438:  <\/p>\n<ul>\n<li><code>Forrest<\/code>;<\/li>\n<li><code>Run<\/code>;<\/li>\n<li><code>Array(speed, distance).<\/code><\/li>\n<\/ul>\n<p>  \u0418\u043d\u043a\u0430\u043f\u0441\u0443\u043b\u044f\u0446\u0438\u044f \u0434\u0435\u043b\u0430\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441 \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0431\u043e\u043b\u0435\u0435 \u0433\u0438\u0431\u043a\u0438\u043c: \u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u043c\u0435\u0436\u0434\u0443 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438, \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c, \u043c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u043f\u043e\u043c\u0435\u0449\u0430\u0442\u044c \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c\u2026 \u0436\u043e\u043d\u0433\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u0432 \u043e\u0431\u0449\u0435\u043c. Apple \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u044d\u0442\u043e\u0442 \u043f\u0430\u0442\u0442\u0435\u0440\u043d \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0430 \u00ab\u0446\u0435\u043b\u044c-\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435\u00bb (Target-Action) \u0438 \u0432\u044b\u0437\u043e\u0432\u0430 (Invocation).<\/p>\n<p>  \u041f\u0440\u043e Target-Action \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c <a href=\"https:\/\/developer.apple.com\/library\/ios\/documentation\/General\/Conceptual\/CocoaEncyclopedia\/Target-Action\/Target-Action.html\">\u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 Apple<\/a>. \u0414\u043b\u044f \u0432\u044b\u0437\u043e\u0432\u043e\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043a\u043b\u0430\u0441\u0441 <code>NSInvocation<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0446\u0435\u043b\u0435\u0432\u043e\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 (\u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043e \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435), \u0441\u0435\u043b\u0435\u043a\u0442\u043e\u0440 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0438 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b. \u042d\u0442\u043e\u0442 \u043e\u0431\u044a\u0435\u043a\u0442 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0451\u043d \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438 \u0438, \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0436\u0435, \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d \u043f\u0440\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438. \u041e\u0442\u043b\u0438\u0447\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0430 \u00ab\u041a\u043e\u043c\u0430\u043d\u0434\u0430\u00bb, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u0430\u0451\u0442 \u043d\u0430\u043c \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043a\u043e\u0434\u0430 (\u043c\u0435\u043d\u044c\u0448\u0435 \u0441\u0432\u044f\u0437\u043d\u043e\u0441\u0442\u044c =&gt; \u0431\u043e\u043b\u044c\u0448\u0435 \u0433\u0438\u0431\u043a\u043e\u0441\u0442\u044c \u0432 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445). \u041e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u0435\u043b\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u043e\u0442\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0442 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u0435\u043b\u044f, \u0438 \u0437\u0430\u043f\u0440\u043e\u0441 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u043e\u0439\u0442\u0438 \u043f\u043e \u0446\u0435\u043f\u043e\u0447\u043a\u0435.<\/p>\n<h3>\u041a\u0430\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0430\u0442\u0442\u0435\u0440\u043d \u00ab\u041a\u043e\u043c\u0430\u043d\u0434\u0430\u00bb<\/h3>\n<p>  \u041f\u0435\u0440\u0435\u0434 \u0442\u0435\u043c, \u043a\u0430\u043a \u043f\u043e\u0433\u0440\u0443\u0437\u0438\u0442\u044c\u0441\u044f \u0432 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u0432\u044b\u0437\u043e\u0432\u043e\u0432, \u043c\u044b \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u043c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043e\u0442\u043c\u0435\u043d\u044b \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439. \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c <code>UIToolbar<\/code> \u0438 <code>NSMutableArray<\/code> \u0434\u043b\u044f \u0441\u0442\u0435\u043a\u0430 \u043e\u0442\u043c\u0435\u043d\u044b \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439 (undo stack).<\/p>\n<p>  \u0414\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434 \u0432 <b>ViewController.m<\/b> \u043a \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044e \u043a\u043b\u0430\u0441\u0441\u0430 <code>ViewController<\/code>, \u0433\u0434\u0435 \u043c\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043b\u0438 \u0432\u0441\u0435 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435:<\/p>\n<pre><code class=\"cpp\">UIToolbar * toolbar; NSMutableArray * undoStack; \/\/ \u043c\u0430\u0441\u0441\u0438\u0432 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439 \u043e\u0442\u043c\u0435\u043d\u044b, \u043d\u0430\u0434 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 push \u0438 pop <\/code><\/pre>\n<p>  \u042d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u0430\u043d\u0435\u043b\u044c \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432, \u043f\u0440\u043e\u0449\u0435 \u0433\u043e\u0432\u043e\u0440\u044f \u2014 \u0442\u0443\u043b\u0431\u0430\u0440 \u0441 \u043a\u043d\u043e\u043f\u043a\u0430\u043c\u0438 \u0434\u043b\u044f \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439. \u0410 \u0442\u0430\u043a\u0436\u0435 \u043c\u0430\u0441\u0441\u0438\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0438\u0433\u0440\u0430\u0442\u044c \u0440\u043e\u043b\u044c \u0441\u0442\u0435\u043a\u0430 \u043a\u043e\u043c\u0430\u043d\u0434.<\/p>\n<p>  \u0414\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434 \u0432 \u043d\u0430\u0447\u0430\u043b\u043e <code>viewDidLoad:<\/code> \u043f\u0440\u044f\u043c\u043e \u043f\u0435\u0440\u0435\u0434 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0435\u043c &quot;<code>\/\/ 2<\/code>&quot;:<\/p>\n<pre><code class=\"cpp\">toolbar = [[UIToolbar alloc] init];  UIBarButtonItem * undoItem = [[UIBarButtonItem alloc]         initWithBarButtonSystemItem:UIBarButtonSystemItemUndo                              target:self                              action:@selector(undoAction)]; undoItem.enabled = NO;  UIBarButtonItem * space = [[UIBarButtonItem alloc]         initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace                              target:nil                              action:nil];  UIBarButtonItem * delete = [[UIBarButtonItem alloc]          initWithBarButtonSystemItem:UIBarButtonSystemItemTrash                              target:self                              action:@selector(deleteAlbum)];  [toolbar setItems:@[undoItem, space, delete]]; [self.view addSubview:toolbar];  undoStack = [[NSMutableArray alloc] init]; <\/code><\/pre>\n<p>  \u042d\u0442\u0438 \u0441\u0442\u0440\u043e\u043a\u0438 \u0441\u043e\u0437\u0434\u0430\u044e\u0442 \u0442\u0443\u043b\u0431\u0430\u0440 \u0441 \u0434\u0432\u0443\u043c\u044f \u043a\u043d\u043e\u043f\u043a\u0430\u043c\u0438 \u0438 \u0433\u0438\u0431\u043a\u043e\u0435 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e \u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c\u0438 (\u0433\u0438\u0431\u043a\u043e\u0435 = \u043f\u043e\u0434\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u0434 \u0448\u0438\u0440\u0438\u043d\u0443 \u044d\u043a\u0440\u0430\u043d\u0430). \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0437\u0434\u0435\u0441\u044c \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043f\u0443\u0441\u0442\u043e\u0439 \u0441\u0442\u0435\u043a \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439. \u041a\u043d\u043e\u043f\u043a\u0430 Undo \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u043e\u0442\u043a\u043b\u044e\u0447\u0435\u043d\u0430, \u0442.\u043a. \u0441\u0442\u0435\u043a \u043f\u0443\u0441\u0442\u043e\u0439.<\/p>\n<p>  \u0417\u0430\u043c\u0435\u0442\u0438\u043c, \u0447\u0442\u043e \u0442\u0443\u043b\u0431\u0430\u0440 \u0438\u043d\u0438\u0446\u0438\u0438\u0440\u043e\u0432\u0430\u043d \u0431\u0435\u0437 frame, \u0442.\u0435. \u043c\u044b \u043d\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u0435\u0433\u043e \u0433\u0440\u0430\u043d\u0438\u0446 \u0437\u0434\u0435\u0441\u044c. \u0414\u0435\u043b\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0433\u0440\u0430\u043d\u0438\u0446\u044b \u0432 <code>viewDidLoad<\/code> \u043d\u0435 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043e\u043a\u043e\u043d\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c\u0438. \u041c\u044b \u043d\u0430\u0439\u0434\u0451\u043c \u043e\u043a\u043e\u043d\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0433\u0440\u0430\u043d\u0438\u0446\u044b \u043f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a <code>ViewController<\/code> \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u0442 \u00ab\u043a\u0430\u0434\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u00bb. \u0414\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043c\u0435\u0442\u043e\u0434 \u0432 <b>ViewController.m<\/b>:<\/p>\n<pre><code class=\"cpp\">- (void)viewWillLayoutSubviews {     toolbar.frame = CGRectMake(0, self.view.frame.size.height - 44, self.view.frame.size.width, 44);     dataTable.frame = CGRectMake(0, 130, self.view.frame.size.width, self.view.frame.size.height - 200); } <\/code><\/pre>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u043c\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0442\u0440\u0438 \u043c\u0435\u0442\u043e\u0434\u0430 \u0432 <b>ViewController.m<\/b> \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043f\u043e \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044e \u0430\u043b\u044c\u0431\u043e\u043c\u0430\u043c\u0438: \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435, \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0438 \u043e\u0442\u043c\u0435\u043d\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0433\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f.<\/p>\n<p>  \u041f\u0435\u0440\u0432\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u2014 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043d\u043e\u0432\u043e\u0433\u043e \u0430\u043b\u044c\u0431\u043e\u043c\u0430:<\/p>\n<pre><code class=\"cpp\">- (void)addAlbum:(Album *)album atIndex:(int)index {     [[LibraryAPI sharedInstance] addAlbum:album atIndex:index];     currentAlbumIndex = index;     [self reloadScroller]; } <\/code><\/pre>\n<p>  \u0417\u0434\u0435\u0441\u044c \u043c\u044b \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0430\u043b\u044c\u0431\u043e\u043c, \u00ab\u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c\u00bb \u043a \u043d\u0435\u043c\u0443 (\u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u0438\u043d\u0434\u0435\u043a\u0441) \u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c \u0441\u043a\u0440\u043e\u043b\u043b\u0435\u0440.<\/p>\n<p>  \u0414\u0430\u043b\u0435\u0435, \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435:<\/p>\n<pre><code class=\"cpp\">- (void)deleteAlbum {     \/\/ 1     Album * deletedAlbum = allAlbums[currentAlbumIndex];      \/\/ 2     NSMethodSignature * sig = [self methodSignatureForSelector:@selector(addAlbum:atIndex:)];     NSInvocation * undoDeleteAction = [NSInvocation invocationWithMethodSignature:sig];     [undoDeleteAction setTarget:self];     [undoDeleteAction setSelector:@selector(addAlbum:atIndex:)];     [undoDeleteAction setArgument:&amp;deletedAlbum atIndex:2];     [undoDeleteAction setArgument:&amp;currentAlbumIndex atIndex:3];     [undoDeleteAction retainArguments];      \/\/ 3     [undoStack addObject:undoDeleteAction];      \/\/ 4     [[LibraryAPI sharedInstance] deleteAlbumAtIndex:currentAlbumIndex];     [self reloadScroller];      \/\/ 5     [toolbar.items[0] setEnabled:YES]; } <\/code><\/pre>\n<p>  \u0422\u0443\u0442 \u0435\u0441\u0442\u044c \u043d\u043e\u0432\u044b\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u044d\u0442\u043e\u0442 \u043a\u043e\u0434 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435:<\/p>\n<ol>\n<li> \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u0430\u043b\u044c\u0431\u043e\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0443\u0436\u043d\u043e \u0443\u0434\u0430\u043b\u0438\u0442\u044c.<\/li>\n<li> \u0421\u043e\u0437\u0434\u0430\u0451\u043c \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u0443 \u043c\u0435\u0442\u043e\u0434\u0430 (\u043e\u0431\u044a\u0435\u043a\u0442 \u043a\u043b\u0430\u0441\u0441\u0430 <code>NSMethodSignature<\/code>). \u0418 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u044b \u0441\u043e\u0437\u0434\u0430\u0451\u043c \u043e\u0431\u044a\u0435\u043a\u0442 <code>NSInvocation<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u043b\u044f \u043e\u0442\u043c\u0435\u043d\u044b \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u2014 <code>undoDeleteAction<\/code>.<br \/>  <code>NSInvocation<\/code> \u0434\u043e\u043b\u0436\u0435\u043d \u0437\u043d\u0430\u0442\u044c \u0442\u0440\u0438 \u0432\u0435\u0449\u0438:<br \/> \n<ul>\n<li> <u>\u0446\u0435\u043b\u044c<\/u> \u2014 \u043e\u0431\u044a\u0435\u043a\u0442, \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435;<\/li>\n<li> <u>\u0441\u0435\u043b\u0435\u043a\u0442\u043e\u0440<\/u> \u2014 \u043a\u0430\u043a\u043e\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c;<\/li>\n<li> <u>\u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b<\/u> \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f.<\/li>\n<\/ul>\n<p>\u0412 \u043d\u0430\u0448\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435, \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u00ab\u0443\u0434\u0430\u043b\u0438\u0442\u044c\u00bb. \u0410 \u0437\u043d\u0430\u0447\u0438\u0442 \u2014 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c, \u0432\u0435\u0440\u043d\u0443\u0442\u044c \u0443\u0434\u0430\u043b\u0451\u043d\u043d\u044b\u0439 \u0430\u043b\u044c\u0431\u043e\u043c.<\/li>\n<li> \u041a\u043e\u0433\u0434\u0430 \u0443 \u043d\u0430\u0441 \u0441\u043e\u0437\u0434\u0430\u043d\u043e <code>undoDeleteAction<\/code>, \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0435\u0433\u043e \u0432 \u0432\u043e\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u043c\u044b\u0439 \u00ab\u0441\u0442\u0435\u043a\u00bb\u2026<br \/>  <i>\u041d\u0438\u043a\u043e\u0433\u0434\u0430 \u0442\u0430\u043a \u043d\u0435 \u0434\u0435\u043b\u0430\u0439\u0442\u0435! \u0410\u0432\u0442\u043e\u0440 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043c\u0430\u0441\u0441\u0438\u0432 \u0441\u0442\u0435\u043a\u043e\u043c. \u0422\u0438\u043f\u0430, \u00ab\u0447\u0435\u043b\u043e\u0432\u0435\u043a, \u0447\u0438\u0442\u0430\u044e\u0449\u0438\u0439 \u043a\u043e\u0434, \u0434\u043e\u043b\u0436\u0435\u043d \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c, \u0447\u0442\u043e \u043c\u0430\u0441\u0441\u0438\u0432 \u2014 \u044d\u0442\u043e \u0441\u0442\u0435\u043a\u00bb\u2026 \u0425\u043e\u0442\u0438\u0442\u0435 \u0441\u0442\u0435\u043a? \u0414\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u0434\u0432\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438: <code>push<\/code> \u0438 <code>pop<\/code>. \u0412\u0441\u0451. \u2014 \u041f\u0440\u0438\u043c. \u043f\u0435\u0440.<\/i><\/li>\n<li> \u0423\u0434\u0430\u043b\u0438\u0442\u0435 \u0430\u043b\u044c\u0431\u043e\u043c \u0438\u0437 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>LibraryAPI<\/code> \u0438 \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u0435 \u0441\u043a\u0440\u043e\u043b\u043b\u0435\u0440.<\/li>\n<li> \u0423 \u043d\u0430\u0441 \u043f\u043e\u044f\u0432\u0438\u043b\u043e\u0441\u044c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043c\u043e\u0436\u043d\u043e \u043e\u0442\u043c\u0435\u043d\u0438\u0442\u044c, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0440\u0430\u0437\u0440\u0435\u0448\u0438\u0442\u044c \u043d\u0430\u0436\u0430\u0442\u0438\u0435 \u043a\u043d\u043e\u043f\u043a\u0438 <b>Undo<\/b>.<\/li>\n<\/ol>\n<p>  <b>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435.<\/b> \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0441\u0445\u0435\u043c\u0443 <code>NSInvocation<\/code>, \u043d\u0443\u0436\u043d\u043e \u0438\u043c\u0435\u0442\u044c \u0432 \u0432\u0438\u0434\u0443 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:  <\/p>\n<ul>\n<li> \u0410\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u044b \u043f\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044e.<\/li>\n<li> \u041d\u0443\u043c\u0435\u0440\u0430\u0446\u0438\u044f \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0441 \u0438\u043d\u0434\u0435\u043a\u0441\u0430 <code>2<\/code>. \u0418\u043d\u0434\u0435\u043a\u0441\u044b <code>0<\/code> \u0438 <code>1<\/code> \u0437\u0430\u0440\u0435\u0437\u0435\u0440\u0432\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u0434\u043b\u044f \u0446\u0435\u043b\u0438 \u0438 \u0441\u0435\u043b\u0435\u043a\u0442\u043e\u0440\u0430.<\/li>\n<li> \u0415\u0441\u043b\u0438 \u0435\u0441\u0442\u044c \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c \u043e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0438\u0437 \u043f\u0430\u043c\u044f\u0442\u0438, \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0432\u044b\u0437\u0432\u0430\u0442\u044c <code>retainArguments<\/code>.<\/li>\n<\/ul>\n<p>  \u041d\u0430\u043a\u043e\u043d\u0435\u0446, \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u043c\u0435\u0442\u043e\u0434 \u0434\u043b\u044f \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u00ab\u043e\u0442\u043c\u0435\u043d\u0438\u0442\u044c\u00bb:<\/p>\n<pre><code class=\"cpp\">- (void)undoAction {     if (undoStack.count &gt; 0)     {         NSInvocation * undoAction = [undoStack lastObject];         [undoStack removeLastObject];         [undoAction invoke];     }      if (undoStack.count == 0)     {         [toolbar.items[0] setEnabled:NO];     } } <\/code><\/pre>\n<p>  \u0417\u0434\u0435\u0441\u044c \u043c\u044b \u0432\u0438\u0434\u0438\u043c \u0438\u043c\u0438\u0442\u0430\u0446\u0438\u044e \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0438\u0437 \u0441\u0442\u0435\u043a\u0430 \u0432 \u0434\u0432\u0430 \u043c\u0435\u0442\u043e\u0434\u0430: <code>lastObject<\/code> + <code>removeLastObject<\/code>. \u041a\u043e\u043d\u0435\u0447\u043d\u043e, <code>ViewController<\/code> \u043d\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u0434\u0443\u043c\u0430\u0442\u044c \u043e \u0442\u0430\u043a\u0438\u0445 \u0432\u0435\u0449\u0430\u0445. \u0421\u0434\u0435\u043b\u0430\u0442\u044c \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u0442\u0435\u043a \u2014 \u0432\u043e\u0442 \u0432\u0430\u043c \u0434\u043e\u043c\u0430\u0448\u043d\u0435\u0435 \u0437\u0430\u0434\u0430\u043d\u0438\u0435 \u043e\u0442 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0447\u0438\u043a\u0430 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438.<\/p>\n<p>  \u041c\u044b \u0434\u043e\u0441\u0442\u0430\u0451\u043c \u0438\u0437 \u0441\u0442\u0435\u043a\u0430 \u043a\u0440\u0430\u0439\u043d\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442, \u043e\u043d \u0432\u0441\u0435\u0433\u0434\u0430 \u0438\u043c\u0435\u0435\u0442 \u0442\u0438\u043f <code>NSInvocation<\/code> \u0438 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0432\u044b\u0437\u0432\u0430\u043d \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u0435\u0442\u043e\u0434\u0430 <code>invoke<\/code>. \u0422\u0435\u043c \u0441\u0430\u043c\u044b\u043c, \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u0430, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u043b\u0438 \u0432\u044b\u0448\u0435 (\u043f\u0440\u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0438 \u0430\u043b\u044c\u0431\u043e\u043c\u0430) \u2014 \u0430 \u043e\u043d\u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0443\u0434\u0430\u043b\u0451\u043d\u043d\u044b\u0439 \u0430\u043b\u044c\u0431\u043e\u043c \u0432 \u0441\u043f\u0438\u0441\u043e\u043a.<\/p>\n<p>  \u042d\u043b\u0435\u043c\u0435\u043d\u0442, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0439 \u0438\u0437 \u0441\u0442\u0435\u043a\u0430, \u0443\u0434\u0430\u043b\u044f\u0435\u0442\u0441\u044f \u0438\u0437 \u043e\u043d\u043e\u0433\u043e. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0438 \u0441\u0442\u0435\u043a \u043f\u0443\u0441\u0442\u044b\u043c. \u0415\u0441\u043b\u0438 \u043e\u043d \u043f\u0443\u0441\u0442\u043e\u0439, \u0442\u043e \u0443 \u043d\u0430\u0441 \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435\u0442 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439 \u0434\u043b\u044f \u043e\u0442\u043c\u0435\u043d\u044b. \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u044b \u0437\u0430\u043f\u0440\u0435\u0449\u0430\u0435\u043c \u043d\u0430\u0436\u0430\u0442\u0438\u0435 \u043a\u043d\u043e\u043f\u043a\u0438 <b>Undo<\/b> (\u043e\u043d\u0430 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0441\u0435\u0440\u043e\u0439).<\/p>\n<p>  \u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c, \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043d\u0430\u0448 \u200b\u200b\u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u043e\u0442\u043c\u0435\u043d\u044b. \u0423\u0434\u0430\u043b\u0438\u0442\u0435 \u043e\u0434\u0438\u043d-\u0434\u0432\u0430 \u0430\u043b\u044c\u0431\u043e\u043c\u0430 \u0438 \u043d\u0430\u0436\u043c\u0438\u0442\u0435 \u043a\u043d\u043e\u043f\u043a\u0443 Undo, \u0447\u0442\u043e\u0431\u044b \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0435\u0451 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435:<\/p>\n<p>  \u0422\u0430\u043a\u0436\u0435 \u0445\u043e\u0440\u043e\u0448\u043e \u0431\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c, \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u044e\u0442\u0441\u044f \u043b\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432 \u0441\u043f\u0438\u0441\u043a\u0435 \u0430\u043b\u044c\u0431\u043e\u043c\u043e\u0432 \u043c\u0435\u0436\u0434\u0443 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u043c\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u0423\u0434\u0430\u043b\u0438\u0442\u0435 \u0430\u043b\u044c\u0431\u043e\u043c, \u043e\u0442\u043f\u0440\u0430\u0432\u044c\u0442\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0432 \u0444\u043e\u043d, \u0430 \u0437\u0430\u0442\u0435\u043c \u0437\u0430\u043a\u0440\u043e\u0439\u0442\u0435 \u0435\u0433\u043e \u0438\u0437 \u043c\u043d\u043e\u0433\u043e\u0437\u0430\u0434\u0430\u0447\u043d\u043e\u0441\u0442\u0438. \u041f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442 \u0441\u043f\u0438\u0441\u043e\u043a \u0430\u043b\u044c\u0431\u043e\u043c\u043e\u0432, \u0432\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u044d\u0442\u043e \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u043f\u0440\u0438 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u0437\u0430\u043f\u0443\u0441\u043a\u0435.<\/p>\n<h2>\u0427\u0442\u043e \u0434\u0430\u043b\u044c\u0448\u0435<\/h2>\n<p>  \u0412 Objective C \u0448\u0438\u0440\u043e\u043a\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0435\u0449\u0451 \u0434\u0432\u0430 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u043b\u0438\u0441\u044c \u0432 \u044d\u0442\u043e\u0442 \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b: \u0410\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u0430\u044f \u0444\u0430\u0431\u0440\u0438\u043a\u0430 (<a href=\"https:\/\/developer.apple.com\/legacy\/library\/documentation\/Cocoa\/Conceptual\/CocoaFundamentals\/CocoaDesignPatterns\/CocoaDesignPatterns.html#\/\/apple_ref\/doc\/uid\/TP40002974-CH6-SW32\">Abstract Factory<\/a>) \u0438 \u0426\u0435\u043f\u043e\u0447\u043a\u0430 \u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0441\u0442\u0438 (<a href=\"https:\/\/developer.apple.com\/legacy\/library\/documentation\/Cocoa\/Conceptual\/CocoaFundamentals\/CocoaDesignPatterns\/CocoaDesignPatterns.html#\/\/apple_ref\/doc\/uid\/TP40002974-CH6-SW25\">Chain of Responsibility<\/a>). \u041e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0438\u0437\u0443\u0447\u0438\u0442\u0435 \u0438\u0445 \u0438 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0439\u0442\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u0432 \u0441\u0432\u043e\u0438\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445.<\/p>\n<p>  \u041c\u044b \u0443\u0432\u0438\u0434\u0435\u043b\u0438, \u0447\u0442\u043e \u0434\u0430\u044e\u0442 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u044b: \u0434\u043b\u044f \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u0437\u0430\u0434\u0430\u0447 \u043f\u043e\u043b\u0443\u0447\u0430\u044e\u0442\u0441\u044f \u043f\u0440\u043e\u0441\u0442\u044b\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f. \u041c\u044b \u0443\u0437\u043d\u0430\u043b\u0438, \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u0441\u0438\u043d\u0433\u043b\u0442\u043e\u043d, MVC, \u0434\u0435\u043b\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435, \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b, \u0444\u0430\u0441\u0430\u0434, \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0442\u0435\u043b\u044c, \u0445\u0440\u0430\u043d\u0438\u0442\u0435\u043b\u044c \u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u0430.<\/p>\n<p>  \u0412\u0430\u0448 \u043a\u043e\u0434 \u0441\u043b\u0430\u0431\u043e \u0441\u0432\u044f\u0437\u0430\u043d, \u0435\u0433\u043e \u043b\u0435\u0433\u043a\u043e \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c, \u043b\u0435\u0433\u043a\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e. \u0415\u0441\u043b\u0438 \u0434\u0440\u0443\u0433\u043e\u0439 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u0442 \u043d\u0430 \u044d\u0442\u043e\u0442 \u043a\u043e\u0434, \u043e\u043d \u0431\u044b\u0441\u0442\u0440\u043e \u043f\u043e\u0439\u043c\u0451\u0442, \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442, \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u043a\u0430\u0436\u0434\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u0432 \u043d\u0430\u0448\u0435\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438.<\/p>\n<p>  \u0420\u0435\u0447\u044c \u043d\u0435 \u043e \u0442\u043e\u043c, \u0447\u0442\u043e\u0431\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u044b \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0432 \u043a\u0430\u0436\u0434\u043e\u0439 \u0441\u0442\u0440\u043e\u0447\u043a\u0435 \u043a\u043e\u0434\u0430. \u041f\u0440\u043e\u0441\u0442\u043e \u0431\u0443\u0434\u044c\u0442\u0435 \u0432 \u043a\u0443\u0440\u0441\u0435 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u043e\u0432, \u043a\u043e\u0433\u0434\u0430 \u0440\u0430\u0437\u043c\u044b\u0448\u043b\u044f\u0435\u0442\u0435, \u043a\u0430\u043a \u0440\u0435\u0448\u0438\u0442\u044c \u0442\u0443 \u0438\u043b\u0438 \u0438\u043d\u0443\u044e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u043d\u0430 \u0440\u0430\u043d\u043d\u0438\u0445 \u0441\u0442\u0430\u0434\u0438\u044f\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0432\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0438 \u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u0434\u0435\u043b\u0430\u044f \u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433. \u041f\u0430\u0442\u0442\u0435\u0440\u043d\u044b \u0434\u0435\u043b\u0430\u044e\u0442 \u0436\u0438\u0437\u043d\u044c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430 \u043d\u0430\u043c\u043d\u043e\u0433\u043e \u043b\u0435\u0433\u0447\u0435, \u0430 \u043a\u043e\u0434 \u2014 \u043b\u0443\u0447\u0448\u0435!<\/p>\n<hr\/>\n<p>  <\/p>\n<h2>\u041e\u0442 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0447\u0438\u043a\u0430 (\u0432\u043c\u0435\u0441\u0442\u043e \u0437\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f)<\/h2>\n<p>  \u0412\u0441\u043f\u043e\u043c\u043d\u0438\u043c \u043d\u0430\u0447\u0430\u043b\u043e \u0441\u0442\u0430\u0442\u044c\u0438: \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u044b \u0432\u043f\u0435\u0440\u0432\u044b\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u044b \u041a\u0440\u0438\u0441\u0442\u043e\u0444\u0435\u0440\u043e\u043c \u0410\u043b\u0435\u043a\u0441\u0430\u043d\u0434\u0435\u0440\u043e\u043c \u0432 \u043a\u043d\u0438\u0433\u0435 \u00ab\u042f\u0437\u044b\u043a \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u043e\u0432\u00bb. <b>\u041f\u0430\u0442\u0442\u0435\u0440\u043d\u044b \u2014 \u044d\u0442\u043e \u044f\u0437\u044b\u043a<\/b>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u044f\u0435\u0442 \u0434\u0432\u0435 \u0432\u0435\u0449\u0438:  <\/p>\n<ol>\n<li>\u041e\u043f\u044b\u0442 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432;<\/li>\n<li>\u042f\u0437\u044b\u043a, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043c\u044b \u0433\u043e\u0432\u043e\u0440\u0438\u043c \u0438 \u043f\u0438\u0448\u0435\u043c.<\/li>\n<\/ol>\n<p>  \u041d\u0430\u0434\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c, \u0447\u0442\u043e \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u044b \u2014 \u044d\u0442\u043e \u0436\u0438\u0432\u043e\u0439 \u044f\u0437\u044b\u043a, \u0438 \u0447\u0442\u043e \u043d\u0435\u0442 \u043f\u0440\u0435\u0434\u0435\u043b\u0430 \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u0441\u0442\u0432\u0443. \u0412 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0439 \u0433\u043b\u0430\u0432\u043d\u0435 \u0447\u0430\u0441\u0442\u043e \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u0435\u0442\u0441\u044f \u0441\u043b\u043e\u0432\u043e \u00ab\u0441\u0442\u0435\u043a\u00bb, \u043d\u043e <i>\u0432&nbsp;\u043a\u043e\u0434\u0435<\/i> \u043f\u043e\u043d\u044f\u0442\u0438\u0435 \u00ab\u0441\u0442\u0435\u043a\u00bb \u043d\u0438\u043a\u0430\u043a \u043d\u0435 \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u043e. \u0427\u0442\u043e \u044d\u0442\u043e \u2014 \u043e\u0431\u044a\u0435\u043a\u0442? \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e? \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c?<\/p>\n<p>  \u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u0437\u0434\u0435\u0441\u044c \u0432\u044b \u0437\u043d\u0430\u0435\u0442\u0435 \u043e\u0442\u0432\u0435\u0442. \u042f \u043a \u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u044d\u0442\u043e \u0437\u043d\u0430\u043d\u0438\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u043e \u0432 \u043a\u043e\u0434\u0435, \u0447\u0442\u043e\u0431\u044b \u0438\u0437\u0431\u0430\u0432\u0438\u0442\u044c\u0441\u044f \u043e\u0442 \u0444\u0440\u0430\u0437\u044b \u00ab\u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043c, \u0447\u0442\u043e <code>NSMutableArray<\/code> \u2014 \u044d\u0442\u043e \u0443 \u043d\u0430\u0441 \u0441\u0442\u0435\u043a\u00bb \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u043a \u0432\u0430\u0448\u0435\u043c\u0443 \u0431\u0443\u0434\u0443\u0449\u0435\u043c\u0443 \u043f\u0440\u043e\u0435\u043a\u0442\u0443. \u041a\u043e\u0434 \u0438 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u0434\u043e\u043b\u0436\u043d\u044b \u043e\u0442\u0440\u0430\u0436\u0430\u0442\u044c \u0434\u0440\u0443\u0433 \u0434\u0440\u0443\u0433\u0430, \u0430 \u043d\u0435 \u0434\u043e\u043f\u043e\u043b\u043d\u044f\u0442\u044c (\u00ab\u0447\u0435\u0433\u043e \u043d\u0435 \u0432\u0438\u0434\u043d\u043e \u0438\u0437 \u043a\u043e\u0434\u0430, \u0432\u044b \u043d\u0430\u0439\u0434\u0451\u0442\u0435 \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438, \u0438 \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442\u00bb).<\/p>\n<p>  \u041a\u0430\u0436\u0434\u0430\u044f \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c, \u043a\u0430\u0436\u0434\u0430\u044f \u0438\u0434\u0435\u044f, \u043e \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043c\u044b \u0433\u043e\u0432\u043e\u0440\u0438\u043c, \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u043a\u0440\u0430\u0441\u0438\u0432\u043e \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0435\u043d\u0430 \u0432 \u043a\u043e\u0434\u0435, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0438\u0439 \u0447\u0435\u043b\u043e\u0432\u0435\u043a, \u0432\u0437\u0433\u043b\u044f\u043d\u0443\u0432 \u043d\u0430 \u043a\u043e\u0434, \u0431\u044b\u0441\u0442\u0440\u043e \u0443\u043b\u043e\u0432\u0438\u043b \u0441\u0443\u0442\u044c. \u00ab\u041a\u0430\u043a \u0443\u0441\u0442\u0440\u043e\u0435\u043d \u043e\u0431\u044a\u0435\u043a\u0442? \u041a\u0430\u043a \u043e\u043d \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0443\u0435\u0442 \u0441 \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438?\u00bb \u2014 \u043f\u0440\u043e\u0441\u0442\u044b\u0435 \u0438 \u0451\u043c\u043a\u0438\u0435 \u043e\u0442\u0432\u0435\u0442\u044b \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 <b>\u0438\u043c\u0435\u043d\u043d\u043e<\/b> \u0432 \u0432\u0438\u0434\u0435 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u043e\u0432.<\/p>\n<p>  \u0418 \u0435\u0449\u0451. \u0412\u0441\u0435\u0433\u0434\u0430 \u0441\u043c\u043e\u0442\u0440\u0438\u0442\u0435 \u043d\u0430 \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u044f \u043e\u0442 IDE. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 \u043a\u043e\u0434\u0435 \u043c\u0435\u0442\u043e\u0434\u0430 <code>showDataForAlbumAtIndex:<\/code> \u043c\u044b \u0441\u0434\u0435\u043b\u0430\u043b\u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 <code>if (albumIndex &lt; allAlbums.count)<\/code>, \u0430 \u043f\u043e\u0447\u0435\u043c\u0443 \u043d\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043b\u0438 <code>(albumIndex &gt; 0)<\/code>? \u0410\u0432\u0442\u043e\u0440 \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b\u0430 \u043e\u0431 \u044d\u0442\u043e\u043c \u043d\u0435 \u043f\u043e\u0434\u0443\u043c\u0430\u043b, \u0430 \u0441\u043e\u0437\u0434\u0430\u0442\u0435\u043b\u0438 \u043a\u043b\u0430\u0441\u0441\u0430 <code>NSArray<\/code> \u043f\u043e\u0434\u0443\u043c\u0430\u043b\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 AppCode \u0441\u0440\u0430\u0437\u0443 \u043f\u043e\u0434\u0441\u0432\u0435\u0447\u0438\u0432\u0430\u0435\u0442:<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage3\/114\/020\/b31\/114020b31dc170580ae03154f105ce4f.png\"\/><\/p>\n<p>  \u0417\u0430\u043c\u0435\u043d\u0438\u0432 <code>int<\/code> \u043d\u0430 <code>NSUInteger<\/code>, \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u044b\u0439 \u043a\u043e\u0434 \u2014 \u0431\u0435\u0437 \u043b\u0438\u0448\u043d\u0438\u0445 \u043f\u0440\u043e\u0432\u0435\u0440\u043e\u043a \u2014 \u00abby design\u00bb.<\/p>\n<h2>P.S.<\/h2>\n<p>  <b>\u041f\u0438\u0448\u0438\u0442\u0435 \u043d\u0430 \u043f\u043e\u0447\u0442\u0443 <i>dev<code>@<\/code>x128<code>.<\/code>ru<\/i>, \u0435\u0441\u043b\u0438 \u0447\u0442\u043e-\u0442\u043e \u043d\u0435\u043f\u043e\u043d\u044f\u0442\u043d\u043e.<\/b><\/p>\n<p>  \u0414\u0430\u043d\u043d\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0430 \u043f\u043e \u043c\u043e\u0442\u0438\u0432\u0430\u043c \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430 <a href=\"https:\/\/developer.apple.com\/legacy\/library\/documentation\/Cocoa\/Conceptual\/CocoaFundamentals\/CocoaDesignPatterns\/CocoaDesignPatterns.html#\/\/apple_ref\/doc\/uid\/TP40002974-CH6-SW6\">Cocoa Design Patterns<\/a> \u043e\u0442 Apple, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443\u0441\u0442\u0430\u0440\u0435\u043b \u043f\u0440\u044f\u043c\u043e \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0430 \u0441\u0442\u0430\u0442\u044c\u0438:<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage3\/0fc\/6b9\/4a8\/0fc6b94a8e03448b48e215b301c500d7.png\"\/><\/p>\n<p>  \u041d\u0430 \u0441\u043c\u0435\u043d\u0443 \u044d\u0442\u043e\u043c\u0443 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0443 \u043f\u0440\u0438\u0448\u043b\u043e \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 <a href=\"https:\/\/developer.apple.com\/library\/mac\/referencelibrary\/GettingStarted\/RoadMapOSX\/books\/StreamlineYourAppswithDesignPatterns\/StreamlineYourApps\/StreamlineYourApps.html\">Streamline Your App with Design Patterns<\/a>, \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0432\u044b\u0431\u0440\u043e\u0448\u0435\u043d\u044b \u0432\u0441\u0435 \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u00abGang of Four\u00bb. \u0421\u043b\u043e\u0433\u0430\u043d \u00abStart Developing Mac Apps Today\u00bb \u043d\u0435\u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c \u0441 <i>\u043a\u0430\u043a\u0438\u043c\u0438-\u0442\u043e<\/i> \u043a\u043d\u0438\u0433\u0430\u043c\u0438. \u041a\u043d\u0438\u0433\u0443 \u0437\u0430 \u0434\u0435\u043d\u044c \u043d\u0435 \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0435\u0448\u044c.<\/p>\n<p>  \u0422\u0435\u043c \u0432\u0430\u0436\u043d\u0435\u0435 \u043d\u0430\u0448\u0430 \u0437\u0430\u0434\u0430\u0447\u0430. \u0423 \u044f\u0437\u044b\u043a\u0430 Objective C \u0435\u0441\u0442\u044c \u0445\u043e\u0440\u043e\u0448\u0438\u0439 \u0448\u0430\u043d\u0441 \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u0442\u044c\u0441\u044f \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0439 ****Script, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043f\u0440\u043e\u0449\u0435 \u0432\u0441\u0435\u0433\u043e \u043f\u0438\u0441\u0430\u0442\u044c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u043c\u0435\u0442\u043e\u0434\u043e\u043c \u043a\u043e\u043f\u0438\u043f\u0430\u0441\u0442\u0430 (\u0438 \u044d\u0442\u043e \u043f\u0440\u0438 \u0436\u0438\u0432\u044b\u0445 \u041e\u041e\u041f-\u043c\u0435\u0442\u043e\u0434\u0438\u043a\u0430\u0445). \u0427\u0442\u043e\u0431\u044b \u044d\u0442\u043e\u0433\u043e \u043d\u0435 \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u043e, \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u043f\u043e\u0442\u0440\u0443\u0434\u0438\u0442\u044c\u0441\u044f.   \t<\/p>\n<div class=\"clear\"><\/div>\n<\/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=\"http:\/\/habrahabr.ru\/post\/202960\/\"> http:\/\/habrahabr.ru\/post\/202960\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">\n<h3>\u041e\u0442 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0447\u0438\u043a\u0430<\/h3>\n<p>  \u0418\u0441\u043a\u0430\u043b\u0438 \u0442\u0443\u0442 \u0434\u0432\u0443\u0445 \u0440\u0443\u0441\u0441\u043a\u043e\u044f\u0437\u044b\u0447\u043d\u044b\u0445 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 \u2014 \u043d\u0430 iOS \u0438 \u043d\u0430 C++ \u043f\u043e\u0434 Windows. \u0412\u0438\u0434\u0435\u043b \u0434\u0435\u0441\u044f\u0442\u043a\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u043d\u044b\u0445 \u0442\u0435\u0441\u0442\u043e\u0432. \u0420\u0430\u0437\u043d\u0438\u0446\u0430 \u0432 \u0437\u043d\u0430\u043d\u0438\u0438 \u041e\u041e\u041f \u043c\u0435\u0436\u0434\u0443 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u0435\u043b\u044f\u043c\u0438 \u0434\u0432\u0443\u0445 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c \u2014 \u043e\u0433\u0440\u043e\u043c\u043d\u0430\u044f. \u041d\u0430 C++ \u043e\u0431\u044b\u0447\u043d\u043e \u043a\u0440\u0430\u0441\u0438\u0432\u044b\u0439 \u0440\u0430\u0441\u0448\u0438\u0440\u044f\u0435\u043c\u044b\u0439 \u043a\u043e\u0434, \u043a\u0430\u043a \u0441\u0430\u043c\u043e \u0441\u043e\u0431\u043e\u0439 \u0440\u0430\u0437\u0443\u043c\u0435\u044e\u0449\u0435\u0435\u0441\u044f. \u041d\u0430 Objective C \u043a\u0430\u0440\u0442\u0438\u043d\u0430 \u0443\u0434\u0440\u0443\u0447\u0430\u044e\u0449\u0430\u044f. \u041f\u043e\u0447\u0442\u0438 \u0432\u0441\u0435 iOS-\u043a\u0430\u043d\u0434\u0438\u0434\u0430\u0442\u044b \u043d\u0435 \u0437\u043d\u0430\u043b\u0438 \u041e\u041e\u041f \u0434\u0430\u043b\u044c\u0448\u0435 <s>\u0441\u0432\u043e\u0435\u0433\u043e&nbsp;\u043d\u043e\u0441\u0430<\/s> <code>NSString<\/code>&#8216;\u043e\u0432 \u0438 <code>AppDelegate<\/code>&#8216;\u043e\u0432.<\/p>\n<p>  \u041f\u043e\u043d\u044f\u0442\u043d\u043e, \u0447\u0442\u043e \u043f\u043b\u044e\u0441\u044b \u0443\u0447\u0430\u0442 \u043f\u043e \u0421\u0442\u0440\u0430\u0443\u0441\u0442\u0440\u0443\u043f\u0443 \u0438 \u00ab\u0431\u0430\u043d\u0434\u0435 \u0447\u0435\u0442\u044b\u0440\u0451\u0445\u00bb, \u0430 Objective C \u2014 \u0431\u043e\u043b\u044c\u0448\u0435 \u043f\u043e \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b\u0430\u043c \u0438 Stack&nbsp;Overflow. \u0424\u0430\u0441\u0442\u0444\u0443\u0434-\u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435 \u043d\u0435 \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043c\u0435\u0441\u0442\u0430 \u043d\u0430 \u0444\u0443\u043d\u0434\u0430\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0432\u043e\u043f\u0440\u043e\u0441\u044b\u2026 \u041d\u043e \u0442\u0430\u043a\u043e\u0439 \u0440\u0430\u0437\u043d\u0438\u0446\u044b \u044f \u043d\u0435 \u043e\u0436\u0438\u0434\u0430\u043b.<\/p>\n<p>  \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u043f\u0435\u0440\u0435\u0432\u0451\u043b \u043f\u043e\u0441\u0442, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0434\u0430\u043d\u044b \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u0435 \u0441\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u043e \u0448\u0430\u0431\u043b\u043e\u043d\u0430\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0441 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u043c\u0438 \u043d\u0430 iOS\u2026 \u00ab\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u0435\u00bb? \u0410\u0433\u0430, \u0437\u043d\u0430\u0447\u0438\u0442, \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0435\u043d\u0438\u0435? \u041d\u0435\u0442, \u043d\u0435 \u0431\u0443\u0434\u0435\u0442. \u0414\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0438\u0435 \u0441\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u0432\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0435 \u0438\u0437 \u043e\u043f\u044b\u0442\u0430, \u0438\u0437 <b>\u043f\u043e\u043f\u044b\u0442\u043e\u043a<\/b> \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043a\u043e\u0434\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u043e\u0432. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c\u0441\u044f, \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e, \u0444\u0430\u0441\u0430\u0434 \u0437\u0434\u0430\u043d\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u0442\u043e\u0440\u0447\u0430\u0442\u044c \u0438\u0437 \u0434\u044b\u043c\u043e\u0432\u043e\u0439 \u0442\u0440\u0443\u0431\u044b, \u043d\u043e \u043f\u043e\u0442\u043e\u043c \u043f\u0440\u0438\u0434\u0451\u0442 \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0433\u0434\u0435 \u043a\u0430\u043a\u0438\u0435 \u043f\u0440\u0438\u0451\u043c\u044b \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u043f\u043e\u043c\u043e\u0433\u0430\u044e\u0442.<\/p>\n<p>  \u041a\u0430\u0447\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u0430\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u041f\u041e \u2014 \u0442\u0432\u043e\u0440\u0447\u0435\u0441\u043a\u0438\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441, \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0439 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0439 \u0433\u043e\u043b\u043e\u0432\u044b. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043e\u0431\u0449\u0435\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438: <code>if&nbsp;(A&nbsp;and&nbsp;(B&nbsp;or&nbsp;C)) then&nbsp;use&nbsp;Pattern_N;<\/code><\/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-202960","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/202960","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=202960"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/202960\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=202960"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=202960"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=202960"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}