{"id":192960,"date":"2013-09-15T16:17:02","date_gmt":"2013-09-15T12:17:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=192960"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=192960","title":{"rendered":"<span class=\"post_title\">Core Data \u0434\u043b\u044f iOS. \u0413\u043b\u0430\u0432\u0430 \u21163. \u0422\u0435\u043e\u0440\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0447\u0430\u0441\u0442\u044c<\/span>"},"content":{"rendered":"<div class=\"content html_format\">   \t\u0425\u0430\u0431\u0440\u0430\u043b\u044e\u0434\u0438, \u0434\u043e\u0431\u0440\u044b\u0439 \u0434\u0435\u043d\u044c!<br \/>  \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u0445\u043e\u0447\u0443 \u043d\u0430\u0447\u0430\u0442\u044c \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0440\u044f\u0434\u0430 \u043b\u0435\u043a\u0446\u0438\u0439 \u0441 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u043c\u0438 \u0437\u0430\u0434\u0430\u043d\u0438\u044f\u043c\u0438 \u043f\u043e \u043a\u043d\u0438\u0433\u0435 \u041c\u0438\u0445\u0430\u0435\u043b\u044f \u041f\u0440\u0438\u0432\u0430\u0442\u0430 \u0438 \u0420\u043e\u0431\u0435\u0440\u0442\u0430 \u0412\u0430\u0440\u043d\u0435\u0440\u0430 \u00abPro Core Data for iOS\u00bb, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u043e\u0436\u0435\u0442\u0435 \u043a\u0443\u043f\u0438\u0442\u044c \u043f\u043e <a href=\"http:\/\/www.apress.com\/9781430236566\">\u044d\u0442\u043e\u0439<\/a> \u0441\u0441\u044b\u043b\u043a\u0435. \u041a\u0430\u0436\u0434\u0430\u044f \u0433\u043b\u0430\u0432\u0430 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0442\u0435\u043e\u0440\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u0438 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u0447\u0430\u0441\u0442\u044c.<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage3\/f39\/8f2\/7fe\/f398f27fe69976e2305f4055fc97c9b2.png\"\/><\/p>\n<p>  \u0421\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0435:  <\/p>\n<ul>\n<li> <a href=\"http:\/\/habrahabr.ru\/post\/191334\/\">\u0413\u043b\u0430\u0432\u0430 \u21161. \u041f\u0440\u0438\u0441\u0442\u0443\u043f\u0430\u0435\u043c<\/a> (<a href=\"http:\/\/habrahabr.ru\/post\/191472\/\">\u041f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0447\u0430\u0441\u0442\u044c<\/a>) <\/li>\n<li> <a href=\"http:\/\/habrahabr.ru\/post\/191580\/\">\u0413\u043b\u0430\u0432\u0430 \u21162. \u0423\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u043c Core Data<\/a> (<a href=\"http:\/\/habrahabr.ru\/post\/192090\/\">\u041f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0447\u0430\u0441\u0442\u044c<\/a>)<\/li>\n<li> <a href=\"http:\/\/habrahabr.ru\/post\/192960\/\">\u0413\u043b\u0430\u0432\u0430 \u21163. \u0425\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445: SQLite \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b<\/a><\/li>\n<li> \u0413\u043b\u0430\u0432\u0430 \u21164. \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0445<\/li>\n<li> \u0413\u043b\u0430\u0432\u0430 \u21165. \u0420\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u0441 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0445<\/li>\n<li> \u0413\u043b\u0430\u0432\u0430 \u21166. \u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0438\u0440\u0443\u044e\u0449\u0438\u0445 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432<\/li>\n<li> \u0413\u043b\u0430\u0432\u0430 \u21167. \u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438<\/li>\n<li> \u0413\u043b\u0430\u0432\u0430 \u21168. \u0423\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0432\u0435\u0440\u0441\u0438\u044f\u043c\u0438 \u0438 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438<\/li>\n<li> \u0413\u043b\u0430\u0432\u0430 \u21169. \u0423\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u043c\u0438 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c NSFetchedResultsController<\/li>\n<li> \u0413\u043b\u0430\u0432\u0430 \u211610. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 Core Data \u0432 \u043f\u0440\u043e\u0434\u0432\u0438\u043d\u0443\u0442\u044b\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u0445<\/li>\n<\/ul>\n<p>  <a name=\"habracut\"><\/a><\/p>\n<h5>\u0412\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u0435<\/h5>\n<p>  \u0412 \u044d\u0442\u043e\u0439 \u0433\u043b\u0430\u0432\u0435 \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0441 \u0434\u0432\u0443\u043c\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u043c\u0438 \u0438 \u00ab\u043e\u0434\u0438\u043d-\u043a\u043e-\u043c\u043d\u043e\u0433\u0438\u043c\u00bb \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435\u043c \u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c\u0438. \u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u044c\u0442\u0435, \u0447\u0442\u043e \u0432\u044b \u0432\u044b\u0437\u0432\u0430\u043b\u0438\u0441\u044c \u0434\u043e\u0431\u0440\u043e\u0432\u043e\u043b\u044c\u0446\u0435\u043c \u0441\u043b\u0435\u0434\u0438\u0442\u044c \u0437\u0430 \u043a\u043e\u043c\u0430\u043d\u0434\u0430\u043c\u0438 \u0438\u0437 \u043c\u043b\u0430\u0434\u0448\u0435\u0439 \u0444\u0443\u0442\u0431\u043e\u043b\u044c\u043d\u043e\u0439 \u043b\u0438\u0433\u0438 \u0438 \u0438\u0445 \u0441\u043e\u0441\u0442\u0430\u0432\u043e\u043c. \u0412 \u043d\u0430\u0448\u0435\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0431\u0443\u0434\u0435\u0442 \u0434\u0432\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b: Team (\u0445\u0440\u0430\u043d\u0438\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u043d\u0430\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0438 \u0446\u0432\u0435\u0442\u0435 \u0438\u0445 \u0444\u043e\u0440\u043c\u044b) \u0438 Player (\u0445\u0440\u0430\u043d\u0438\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e\u0431 \u0438\u0433\u0440\u043e\u043a\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u2014 \u043f\u043e\u0447\u0442\u043e\u0432\u044b\u0439 \u044f\u0449\u0438\u043a, \u0438\u043c\u044f \u0438 \u0444\u0430\u043c\u0438\u043b\u0438\u044e). \u041f\u043e\u043d\u044f\u0442\u043d\u043e, \u0447\u0442\u043e \u0443 \u043e\u0434\u043d\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0438\u0433\u0440\u043e\u043a\u043e\u0432, \u0430 \u0438\u0433\u0440\u043e\u043a \u043f\u0440\u0438\u043d\u0430\u0434\u043b\u0435\u0436\u0438\u0442 \u043e\u0434\u043d\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u0435. <br \/>  \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043c\u044b \u044d\u0442\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0441\u043f\u0435\u0440\u0432\u0430 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c SQLite \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430, \u0430 \u043f\u043e\u0442\u043e\u043c \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u0440\u0443\u0433\u0438\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b (\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 \u0438 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u044b\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430 (atomic store)).<\/p>\n<h5>\u0418\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441<\/h5>\n<p>  \u041d\u0430\u0448\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0430\u0437\u043e\u0432\u0451\u043c League Manager \u0438 \u0441\u043e\u0441\u0442\u043e\u044f\u0442\u044c \u043e\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0438\u0437 4 \u044d\u043a\u0440\u0430\u043d\u043e\u0432:  <\/p>\n<ul>\n<li> \u0421\u043f\u0438\u0441\u043e\u043a \u043a\u043e\u043c\u0430\u043d\u0434 <\/li>\n<li> \u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c\/\u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u0443 <\/li>\n<li> \u0421\u043f\u0438\u0441\u043e\u043a \u0438\u0433\u0440\u043e\u043a\u043e\u0432 <\/li>\n<li> \u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c \/\u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u0433\u0440\u043e\u043a\u0430 <\/li>\n<\/ul>\n<p>  \u042d\u043a\u0440\u0430\u043d \u0441\u043e \u0441\u043f\u0438\u0441\u043a\u043e\u043c \u043a\u043e\u043c\u0430\u043d\u0434 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u043d\u044b\u0435 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e \u0444\u0443\u0442\u0431\u043e\u043b\u044c\u043d\u044b\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0441 \u0446\u0432\u0435\u0442\u0430\u043c\u0438 \u0438\u0445 \u0444\u043e\u0440\u043c\u044b. \u041d\u0430 \u044d\u043a\u0440\u0430\u043d\u0435 \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043a\u043d\u043e\u043f\u043a\u0430 <code>+<\/code> \u0434\u043b\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043d\u043e\u0432\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0438 \u043a\u043d\u043e\u043f\u043a\u0430 <code>Edit<\/code> \u0434\u043b\u044f \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f. \u0412\u043e\u0442 \u043a\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u044d\u043a\u0440\u0430\u043d:<br \/>  <img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/3c3\/fbc\/0a9\/3c3fbc0a92605d51deb9437481fa3575.png\" alt=\"image\"\/><\/p>\n<p>  \u042d\u043a\u0440\u0430\u043d \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f\/\u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0444\u0443\u0442\u0431\u043e\u043b\u044c\u043d\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u0434\u0432\u0443\u0445 \u043f\u043e\u043b\u0435\u0439 \u0434\u043b\u044f \u0432\u0432\u043e\u0434\u0430 \u043d\u0430\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0438 \u0446\u0432\u0435\u0442\u0430 \u0438\u0445 \u0444\u043e\u0440\u043c\u044b. \u0414\u0430\u043d\u043d\u044b\u0439 \u044d\u043a\u0440\u0430\u043d \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u0441\u043b\u0435 \u043d\u0430\u0436\u0430\u0442\u0438\u044f \u043d\u0430 \u043a\u043d\u043e\u043f\u043a\u0443 <code>+<\/code> \u043d\u0430 \u044d\u043a\u0440\u0430\u043d\u0435 \u00ab\u0421\u043f\u0438\u0441\u043e\u043a \u043a\u043e\u043c\u0430\u043d\u0434\u00bb \u0434\u043b\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043d\u043e\u0432\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u044b, \u043b\u0438\u0431\u043e \u043f\u0440\u0438 \u043d\u0430\u0436\u0430\u0442\u0438\u0438 \u043d\u0430 \u043e\u0434\u043d\u0443 \u0438\u0437 \u043a\u043e\u043c\u0430\u043d\u0434 \u0438\u0437 \u0441\u043f\u0438\u0441\u043a\u0430 \u0434\u043b\u044f \u0435\u0451 \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f.<br \/>  <img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/7b5\/621\/d57\/7b5621d57ac6fededba19acdd563ed6b.png\" alt=\"image\"\/><\/p>\n<p>  \u042d\u043a\u0440\u0430\u043d \u0441\u043e \u0441\u043f\u0438\u0441\u043a\u043e\u043c \u0438\u0433\u0440\u043e\u043a\u043e\u0432 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442 \u0432\u0441\u0435\u0445 \u0438\u0433\u0440\u043e\u043a\u043e\u0432 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u044b. \u041f\u0435\u0440\u0435\u0445\u043e\u0434 \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u044d\u043a\u0440\u0430\u043d \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u0441\u043b\u0435 \u043d\u0430\u0436\u0430\u0442\u0438\u044f \u043d\u0430 \u0441\u0438\u043d\u044e\u044e \u0441\u0442\u0440\u0435\u043b\u043e\u0447\u043a\u0443 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d\u0435 \u00ab\u0421\u043f\u0438\u0441\u043e\u043a \u043a\u043e\u043c\u0430\u043d\u0434\u00bb \u043d\u0430\u043f\u0440\u043e\u0442\u0438\u0432 \u043a\u0430\u0436\u0434\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u044b:<br \/>  <img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/55f\/3e2\/d2c\/55f3e2d2c3f64b9cfa5240375a33e878.png\" alt=\"image\"\/><\/p>\n<p>  \u041a\u0430\u043a \u0438 \u0441 \u043a\u043e\u043c\u0430\u043d\u0434\u0430\u043c\u0438, \u043f\u0440\u0438 \u043d\u0430\u0436\u0430\u0442\u0438\u0438 \u043d\u0430 <code>+<\/code> \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u044d\u043a\u0440\u0430\u043d \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043d\u043e\u0432\u043e\u0433\u043e \u0438\u0433\u0440\u043e\u043a\u0430 \u0432 \u043a\u043e\u043c\u0430\u043d\u0434\u0443, \u0430 \u043f\u0440\u0438 \u043d\u0430\u0436\u0430\u0442\u0438\u0438 \u043d\u0430 <code>Edit<\/code> \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e\u0431 \u0438\u0433\u0440\u043e\u043a\u0435.<br \/>  <img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/f35\/dc6\/5d9\/f35dc65d97f226e6cf49d2eaf1d8147c.png\" alt=\"image\"\/><\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0437\u043d\u0430\u0435\u043c <b>\u0447\u0442\u043e<\/b> \u043d\u0430\u043c \u043f\u0440\u0435\u0434\u0441\u0442\u043e\u0438\u0442 \u0434\u0435\u043b\u0430\u0442\u044c, \u043c\u043e\u0436\u0435\u043c \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0430\u0442\u044c.<\/p>\n<h5>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 SQLite \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430<\/h5>\n<p>  \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0425\u041a\u043e\u0434 \u0438 \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043d\u043e\u0432\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442. <br \/>  <img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/651\/d3b\/ea6\/651d3bea6d28aaef83ebc312e2d2f4ee.png\" alt=\"image\"\/><\/p>\n<p>  \u041d\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u0435\u0433\u043e <b>LeagueManager<\/b> \u0438 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u0430 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438 \u043f\u0438\u0448\u0435\u043c <b>book.coredata<\/b>.<br \/>  <img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/13b\/b4d\/f70\/13bb4df7032464b4dedb59fbec178c01.png\" alt=\"image\"\/><\/p>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043f\u0440\u043e\u0435\u043a\u0442\u0430:<br \/>  <img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/3fd\/29d\/b19\/3fd29db199167e9c1be4cb9b25ad6946.png\" alt=\"image\"\/><\/p>\n<p>  \u041d\u0430 \u0434\u0430\u043d\u043d\u043e\u043c \u044d\u0442\u0430\u043f\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0441\u0430\u043c\u044b\u043c \u0432\u0430\u0436\u043d\u044b\u043c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u043c \u0438 \u0447\u0430\u0441\u0442\u044c\u044e \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0445. \u041e\u0442\u043a\u0440\u043e\u0435\u043c <code>*.xcdatamodeld<\/code> \u0432 \u0425\u041a\u043e\u0434\u0435:<br \/>  <img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/dba\/564\/693\/dba5646935a9649ecb541271d1f166d9.png\" alt=\"image\"\/><\/p>\n<p>  \u0423\u0434\u0430\u043b\u0438\u0442\u0435 (\u043d\u0430\u0436\u0430\u0442\u0438\u0435 \u043a\u043b\u0430\u0432\u0438\u0448\u0438 <code>Delete<\/code>) \u0443\u0436\u0435 \u0438\u043c\u0435\u044e\u0449\u0443\u044e\u0441\u044f \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c <code>Event<\/code>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043d\u0430\u043c \u043d\u0435 \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u0441\u044f.<\/p>\n<p>  \u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 <code>Team<\/code>:<br \/>  <img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/c7c\/ef6\/4e4\/c7cef64e4f8370e302c44bfe3231798d.png\" alt=\"image\"\/><\/p>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0434\u0432\u0430 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430 \u0443 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 <code>Team<\/code>:  <\/p>\n<ul>\n<li> name (String) <\/li>\n<li> uniformColor (String) <\/li>\n<\/ul>\n<p>  \u041f\u043e\u043b\u0443\u0447\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u043a\u0430\u0440\u0442\u0438\u043d\u0443:<br \/>  <img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/dea\/c21\/22f\/deac2122f12df79d795470babcbaeb26.png\" alt=\"image\"\/><\/p>\n<p>  \u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u043e\u0434\u0438\u043d \u0442\u0438\u043f \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430 \u0441\u0440\u0430\u0437\u0443 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430\u043c, \u0442\u043e \u0432\u0430\u043c \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0432\u044b\u0434\u0435\u043b\u0438\u0442\u044c \u0438\u0445 \u0438 \u0441\u043f\u0440\u0430\u0432\u0430 \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u043d\u0443\u0436\u043d\u044b\u0439 \u0442\u0438\u043f:<br \/>  <img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/7ae\/774\/bf5\/7ae774bf5feffc1b91b838a7b99b9056.png\" alt=\"image\"\/><\/p>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c <code>Player<\/code> \u0441 \u0442\u0440\u0435\u043c\u044f \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430\u043c\u0438:  <\/p>\n<ul>\n<li> firstName (String) <\/li>\n<li> lastName (String) <\/li>\n<li> email (String) <\/li>\n<\/ul>\n<p>  <img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/d48\/80c\/0ad\/d4880c0ad07d548fc7a783d09f7f8270.png\" alt=\"image\"\/><\/p>\n<h5>\u0421\u0432\u044f\u0437\u044c \u00ab\u043e\u0434\u0438\u043d-\u043a\u043e-\u043c\u043d\u043e\u0433\u0438\u043c\u00bb<\/h5>\n<p>  \u0414\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043d\u043e\u0432\u043e\u0439 \u0441\u0432\u044f\u0437\u0438 \u043c\u0435\u0436\u0434\u0443 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044f\u043c\u0438 <code>Team<\/code> \u0438 <code>Player<\/code> \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043f\u0435\u0440\u0432\u0430 \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c <code>Team<\/code> \u0438 \u0432 \u0440\u0430\u0437\u0434\u0435\u043b\u0435 <code>Relationships<\/code> \u043d\u0430\u0436\u0430\u0442\u044c <code>+<\/code> \u0438 \u043d\u0430\u0437\u0432\u0430\u0442\u044c \u043d\u043e\u0432\u0443\u044e \u0441\u0432\u044f\u0437\u044c <b>players<\/b>, \u0434\u043b\u044f <code>Destination<\/code> \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c <code>Player<\/code>. \u0421\u043f\u0440\u0430\u0432\u0430 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0435 \u0444\u043b\u0430\u0433 \u00abTo-Many Relationship\u00bb \u043f\u0440\u0438 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u0439 \u0441\u0432\u044f\u0437\u0438 <b>players<\/b>. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u0432\u044b\u0431\u0435\u0440\u0438\u0442\u0435 <code>Cascade<\/code> (\u043f\u0440\u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0431\u0443\u0434\u0443\u0442 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u044b \u0432\u0441\u0435 \u0438\u0433\u0440\u043e\u043a\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u044b).<br \/>  <img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/1be\/63d\/32d\/1be63d32d8b3d4081a2d723bdeb03fca.png\" alt=\"image\"\/><\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u0432\u044f\u0437\u044c \u0441\u043e \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u0438\u0433\u0440\u043e\u043a\u0430 (\u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 <code>Player<\/code>). \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 <code>Player<\/code> \u0441\u0432\u044f\u0437\u044c \u043f\u043e\u0434 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c <code>team<\/code>, \u0432 \u043f\u043e\u043b\u0435 <code>Destination<\/code> \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u043c <code>Team<\/code>, \u0430 \u0432 \u043f\u043e\u043b\u0435 <code>Invers<\/code> \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u043c <code>players<\/code> (\u043f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u043d\u0435 \u0437\u0430\u0431\u044b\u0432\u0430\u0435\u043c \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u043f\u043e\u043b\u0435 <code>Inverse<\/code> \u0434\u043b\u044f \u0441\u0432\u044f\u0437\u0438 <code>players<\/code> \u0443 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 <code>Team<\/code>)<br \/>  <img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/8f0\/9b9\/7fa\/8f09b97fadcbd4902ec1f2bd996254be.png\" alt=\"image\"\/><\/p>\n<h5>\u041f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430<\/h5>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0437\u0430\u043d\u044f\u0442\u044c\u0441\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435\u043c \u043a\u043e\u0434\u0430 \u0434\u043b\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u044d\u0442\u0438\u0445 \u0441\u0430\u043c\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445. \u0425\u041a\u043e\u0434 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u0432\u0435\u0441\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0439 \u043a\u043e\u0434 \u0434\u043b\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0441\u043f\u0438\u0441\u043a\u0430 \u043a\u043e\u043c\u0430\u043d\u0434; \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0437\u0430\u0434\u0430\u043d\u0438\u0435\u043c \u0431\u0443\u0434\u0435\u0442 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u043e\u0434\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044f\u043c\u0438 <code>Team<\/code>, \u0430 \u043d\u0435 <code>Event<\/code>.<\/p>\n<p>  \u041d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c \u043c\u0435\u0442\u043e\u0434 \u0434\u043b\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0432 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0435\u0433\u043e \u0432 \u0444\u0430\u0439\u043b <code>MasterViewController.m<\/code>, \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0435 \u0437\u0430\u0431\u044b\u0432 \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0432 <code>MasterViewController.h<\/code>.<br \/>  \u041a\u043e\u0434 \u0432 <code>MasterViewController.h<\/code> \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0435\u043f\u0435\u0440\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:  <\/p>\n<pre><code class=\"objectivec\">#import &lt;UIKit\/UIKit.h&gt; #import &lt;CoreData\/CoreData.h&gt;  @interface MasterViewController : UITableViewController &lt;NSFetchedResultsControllerDelegate&gt;  @property (nonatomic, strong) NSFetchedResultsController *fetchedResultsController; @property (nonatomic, strong) NSManagedObjectContext *managedObjectContext;  - (void)insertTeamWithName:(NSString *)name uniformColor:(NSString *)uniformColor; - (void)saveContext; @end <\/code><\/pre>\n<p>  \u041e\u0442\u043a\u0440\u043e\u0439\u0442\u0435 MasterViewController.m \u0438 \u043f\u043e\u0434\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u0438\u0440\u0443\u0439\u0442\u0435 \u043d\u0430\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0435 \u044d\u043a\u0440\u0430\u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:  <\/p>\n<pre><code class=\"objectivec\">self.title = NSLocalizedString(@&quot;League Manager&quot;, @&quot;League Manager&quot;); <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u043c\u0435\u0442\u043e\u0434 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043d\u043e\u0432\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u044b:  <\/p>\n<pre><code class=\"objectivec\">- (void)insertTeamWithName:(NSString *)name uniformColor:(NSString *)uniformColor {    NSManagedObjectContext *context = [self.fetchedResultsController managedObjectContext];    NSEntityDescription *entity = [[self.fetchedResultsController fetchRequest] entity];    NSManagedObject *newManagedObject = [NSEntityDescription insertNewObjectForEntityForName:[entity name] inManagedObjectContext:context];      [newManagedObject setValue:name forKey:@&quot;name&quot;];    [newManagedObject setValue:uniformColor forKey:@&quot;uniformColor&quot;];     [self saveContext]; } <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u0439\u0434\u0435\u043c \u0441\u0442\u0440\u043e\u043a\u0443 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u044f:  <\/p>\n<pre><code class=\"objectivec\">NSEntityDescription *entity = [NSEntityDescription entityForName:@&quot;Event&quot; inManagedObjectContext:self.managedObjectContext]; <\/code><\/pre>\n<p>  \u0438 \u0437\u0430\u043c\u0435\u043d\u0438\u043c \u043d\u0430:  <\/p>\n<pre><code class=\"objectivec\">NSEntityDescription *entity = [NSEntityDescription entityForName:@&quot;Team&quot; inManagedObjectContext:self.managedObjectContext]; <\/code><\/pre>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u043d\u0435\u0441\u0442\u0438 \u0435\u0449\u0435 \u043e\u0434\u043d\u043e \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u043e\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0432 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434, \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u044d\u0442\u0443 \u0441\u0442\u0440\u043e\u043a\u0443:  <\/p>\n<pre><code class=\"objectivec\">NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] iniWithKey:@&quot;timestamp&quot; ascending:NO]; <\/code><\/pre>\n<p>  \u043d\u0430:  <\/p>\n<pre><code class=\"objectivec\">NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] iniWithKey:@&quot;name&quot; ascending:NO]; <\/code><\/pre>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043d\u043e\u0432\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043c\u044b \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0435\u0433\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u044b\u043b\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u044b:  <\/p>\n<pre><code class=\"objectivec\">   [newManagedObject setValue:name forKey:@&quot;name&quot;];    [newManagedObject setValue:uniformColor forKey:@&quot;uniformColor&quot;]; <\/code><\/pre>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0431\u044b\u043b\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u044b \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0435\u0433\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434 <code>saveContext<\/code>.  <\/p>\n<pre><code class=\"objectivec\">- (void)saveContext {    NSManagedObjectContext *context = [self.fetchedResultsController managedObjectContext];    NSError *error = nil;     if(![context save:&error]){       NSLog(@&quot;Unresolved error %@, %@&quot;, error, [error userInfo]);       abort();    } } <\/code><\/pre>\n<p>  \u041f\u043e\u0434\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u0438\u0440\u0443\u0435\u043c \u0435\u0449\u0435 \u043e\u0434\u0438\u043d \u043c\u0435\u0442\u043e\u0434 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:  <\/p>\n<pre><code class=\"objectivec\">- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {     if (editingStyle == UITableViewCellEditingStyleDelete) {         [self saveContext];     } } <\/code><\/pre>\n<h5>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u044b<\/h5>\n<p>  \u042f\u0447\u0435\u0439\u043a\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0432\u0441\u0451 \u0435\u0449\u0435 \u0441\u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u0434\u043b\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439 <code>Event<\/code>, \u0432\u043c\u0435\u0441\u0442\u043e \u0442\u0440\u0435\u0431\u0443\u0435\u043c\u044b\u0445 <code>Team<\/code> \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439. \u041d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043e\u0442\u043e\u0431\u0440\u0430\u0437\u0438\u0442\u044c \u0432 \u043e\u0434\u043d\u043e\u0439 \u044f\u0447\u0435\u0439\u043a\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0434\u0432\u0435 \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0435: \u0438\u043c\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0438 \u0446\u0432\u0435\u0442 \u0444\u043e\u0440\u043c\u044b \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0438\u0433\u0440\u0430\u0435\u0442 \u044d\u0442\u0430 \u043a\u043e\u043c\u0430\u043d\u0434\u0430. \u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0434\u043e\u0441\u0442\u0438\u0447\u044c \u044d\u0442\u043e\u0433\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043f\u0435\u0440\u0432\u0430 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0441\u0442\u0438\u043b\u044c \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u043c\u043e\u0439 \u044f\u0447\u0435\u0439\u043a\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u043a\u0430\u043a \u0438 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 <code>CellIdentifier<\/code>, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0439 \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 <code>cellForRowAtIndexPath:<\/code>.<br \/>  \u041c\u0435\u043d\u044f\u0435\u043c \u044d\u0442\u0443 \u0441\u0442\u0440\u043e\u043a\u0443:  <\/p>\n<pre><code class=\"objectivec\">static NSString* CellIdentifier = @&quot;Cell&quot;; <\/code><\/pre>\n<p>  \u043d\u0430:  <\/p>\n<pre><code class=\"objectivec\">static NSString* CellIdentifier = @&quot;TeamCell&quot;; <\/code><\/pre>\n<p>  \u0418 \u043c\u0435\u043d\u044f\u0435\u043c \u0442\u0438\u043f \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u0445 \u044f\u0447\u0435\u0435\u043a \u0441 \u0442\u0430\u043a\u0438\u0445:  <\/p>\n<pre><code class=\"objectivec\">cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; <\/code><\/pre>\n<p>  \u043d\u0430:  <\/p>\n<pre><code class=\"objectivec\">cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier]; <\/code><\/pre>\n<p>  \u0412 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u043c \u043a\u043e\u0434\u0435 \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043c\u0435\u0442\u043e\u0434 <code>configureCell:atIndexPath:<\/code>, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u044f\u0447\u0435\u0439\u043a\u0438 \u0434\u043b\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435. \u041d\u043e \u0432 \u0442\u0435\u043a\u0443\u0449\u0435\u043c \u0432\u0438\u0434\u0435, \u043c\u0435\u0442\u043e\u0434 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c\u044e <code>Event<\/code>, \u0430 \u043d\u0435 <code>Team<\/code>, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u043d\u0435\u0441\u0442\u0438 \u043a\u043e\u0435-\u043a\u0430\u043a\u0438\u0435 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u0438\u0432\u044b.  <\/p>\n<pre><code class=\"objectivec\">- (void)configureCell:(UITableViewCell *)cell atIndexPath:(NSIndexPath *)indexPath {    NSManagedObject *managedObject = [self.fetchedResultsController objectAtIndexPath:indexPath];    cell.textLabel.text = [[managedObject valueForKey:@&quot;name&quot;] description];    cell.detailTextLabel.text = [[managedObject valueForKey:@&quot;uniformColor&quot;] description];    cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton; } <\/code><\/pre>\n<h5>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b<\/h5>\n<p>  \u041f\u043e\u043a\u0430 \u043d\u0430\u0448\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043c\u0430\u043b\u043e \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442. \u041e\u043d\u043e \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u0443, \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0438\u0433\u0440\u043e\u043a\u0430. \u0421\u0435\u0439\u0447\u0430\u0441 \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0438\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435, \u0447\u0442\u043e\u0431\u044b \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u043c\u044b \u043d\u0430 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u043c \u043f\u0443\u0442\u0438 \u0438 \u0432\u0441\u0451 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u0415\u0441\u043b\u0438 \u043f\u043e \u043a\u0430\u043a\u0438\u043c-\u0442\u043e \u043f\u0440\u0438\u0447\u0438\u043d\u0430\u043c \u0443 \u0432\u0430\u0441 \u043f\u043e\u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043e\u0448\u0438\u0431\u043a\u0438 \u043f\u0440\u0438 \u0441\u0431\u043e\u0440\u043a\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0442\u043e \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0439\u0442\u0435 \u043f\u0440\u043e\u0439\u0442\u0438 \u0432\u0441\u0435 \u0448\u0430\u0433\u0438 \u0437\u0430\u043d\u043e\u0432\u043e, \u043f\u0435\u0440\u0435\u043f\u0440\u043e\u0432\u0435\u0440\u044c\u0442\u0435 \u043c\u043e\u0434\u0435\u043b\u044c \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>  \u041f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0438\u0437 \u0448\u0430\u0431\u043b\u043e\u043d\u0430 <code>Master-Details View Application<\/code> \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u0435\u0449\u0435 \u043e\u0434\u0438\u043d \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u0441 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c <code>DetailViewController<\/code>. \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u043a\u043b\u0430\u0441\u0441, \u043d\u043e \u0442\u0430\u043a \u043a\u0430\u043a \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u043a\u043e\u043c\u0430\u043d\u0434\u0435 \u0438 \u0438\u0433\u0440\u043e\u043a\u0430\u0445, \u0442\u043e \u043b\u0443\u0447\u0448\u0435 \u0438\u0437\u0431\u0430\u0432\u0438\u0442\u044c\u0441\u044f \u043e\u0442 \u044d\u0442\u043e\u0433\u043e \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430 \u0438 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0435 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u044b \u0441 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u043c\u0438 \u0438\u043c\u0435\u043d\u0430\u043c\u0438.<br \/>  \u0423\u0434\u0430\u043b\u0438\u0442\u0435 \u0441\u0442\u0440\u043e\u043a\u0443 <code>#import DetailViewController.h<\/code> \u0438\u0437 <code>MasterViewController.m<\/code>. \u041d\u0430\u0439\u0434\u0438\u0442\u0435 \u043c\u0435\u0442\u043e\u0434 <code>tableView:didSelectRowAtIndexPath:<\/code> \u0438 \u043e\u0447\u0438\u0441\u0442\u0438\u0442\u0435 \u0435\u0433\u043e \u0442\u0435\u043b\u043e. \u0412\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:  <\/p>\n<pre><code class=\"objectivec\">- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { } <\/code><\/pre>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u043f\u043e\u043a\u043e\u0439\u043d\u043e \u0443\u0434\u0430\u043b\u044f\u0442\u044c \u0432\u0441\u0435 \u0442\u0440\u0438 \u0444\u0430\u0439\u043b\u0430 <code>DetailViewController<\/code> (.h, .m, .xib). \u0415\u0441\u043b\u0438 \u043c\u044b \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0438 \u043d\u0430\u0436\u043c\u0435\u043c \u043d\u0430 \u043a\u043d\u043e\u043f\u043a\u0443 +, \u0442\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0430\u0432\u0430\u0440\u0438\u0439\u043d\u043e \u043f\u0440\u0435\u043a\u0440\u0430\u0449\u0430\u0435\u0442 \u0441\u0432\u043e\u044e \u0440\u0430\u0431\u043e\u0442\u0443. \u042d\u0442\u043e\u0442 + \u043f\u043e \u043f\u0440\u0435\u0436\u043d\u0435\u043c\u0443 \u043f\u0440\u0438\u0432\u044f\u0437\u0430\u043d \u043a \u043c\u0435\u0442\u043e\u0434\u0443 <code>insertNewObject:<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0443\u0434\u0430\u043b\u0438\u043b\u0438. \u041d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0440\u0438\u0432\u044f\u0437\u0430\u0442\u044c \u043a \u044d\u0442\u043e\u0439 \u043a\u043d\u043e\u043f\u043a\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043d\u043e\u0432\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u044b, \u0430 \u0442\u043e\u0447\u043d\u0435\u0435 \u2014 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u043c\u043e\u0434\u0430\u043b\u044c\u043d\u043e\u0435 \u043e\u043a\u043d\u043e \u0441 \u043f\u043e\u043b\u044f\u043c\u0438 \u0434\u043b\u044f \u0432\u0432\u043e\u0434\u0430 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 (\u043d\u0430\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0438 \u0446\u0432\u0435\u0442 \u0444\u043e\u0440\u043c\u044b) \u043e \u043d\u043e\u0432\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u0435. \u042d\u0442\u043e \u0436\u0435 \u043e\u043a\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u043b\u044f \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0443\u0436\u0435 \u0438\u043c\u0435\u044e\u0449\u0438\u0445\u0441\u044f \u043a\u043e\u043c\u0430\u043d\u0434 \u043f\u0440\u0438 \u043d\u0430\u0436\u0430\u0442\u0438\u0438 \u043d\u0430 \u044f\u0447\u0435\u0439\u043a\u0443 \u0441 \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d\u0435 \u0441\u043f\u0438\u0441\u043a\u0430 \u043a\u043e\u043c\u0430\u043d\u0434. <br \/>  \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043d\u043e\u0432\u044b\u0439 \u043a\u043b\u0430\u0441\u0441, \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u0435\u043c \u043d\u0430\u0448\u0435\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u0431\u0443\u0434\u0435\u0442 \u044f\u0432\u043b\u044f\u0442\u044c\u0441\u044f <code>UIViewController<\/code>:<br \/>  <img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/5b6\/281\/d59\/5b6281d59fb8269e2c69edb58758be5c.png\" alt=\"image\"\/><br \/>  \u041d\u0430\u0437\u043e\u0432\u0435\u043c \u044d\u0442\u043e\u0442 \u043a\u043b\u0430\u0441\u0441 <code>TeamViewController<\/code> \u0438 \u043d\u0435 \u0437\u0430\u0431\u044b\u0432\u0430\u0435\u043c \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0433\u0430\u043b\u043e\u0447\u043a\u0443 \u043d\u0430 \u043e\u043f\u0446\u0438\u0438 <code>With XIB for user interface<\/code>.<br \/>  <img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/5ad\/b18\/6e9\/5adb186e9db30d45e9f3a505085bcfbf.png\" alt=\"image\"\/><\/p>\n<p>  \u041e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c <code>TeamViewController.h<\/code>. \u0412 League Manager, \u043a\u043b\u0430\u0441\u0441 <code>MasterViewController<\/code> \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 <code>NSManagedObjectContext<\/code>, \u0437\u043d\u0430\u0447\u0438\u0442 \u0432 <code>TeamViewController<\/code> \u0431\u0443\u0434\u0435\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u0430 \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u044d\u0442\u0443 \u0441\u0440\u0435\u0434\u0443 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438 \u0438 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u043c\u0435\u0442\u043e\u0434 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438. \u0422\u0430\u043a \u043a\u0430\u043a \u0434\u0430\u043d\u043d\u044b\u0439 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u0432\u0435\u0447\u0430\u0442\u044c \u0438 \u0437\u0430 \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u043a\u043e\u043c\u0430\u043d\u0434\u0435, \u0442\u043e \u043f\u0440\u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0441\u0442\u043e\u0438\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442 \u043a\u043e\u043c\u0430\u043d\u0434\u044b (\u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u043c \u0442\u0430\u043a \u0436\u0435 \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432 \u043c\u0435\u0442\u043e\u0434 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438). \u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u044d\u043a\u0440\u0430\u043d\u0430 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f\/\u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0434\u0432\u0430 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0445 \u043f\u043e\u043b\u044f \u2014 \u0434\u043b\u044f \u043d\u0430\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0438 \u0446\u0432\u0435\u0442\u0430 \u0438\u0445 \u0444\u043e\u0440\u043c\u044b, \u0434\u043b\u044f \u043d\u0438\u0445 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0432 <code>TeamViewController<\/code>. \u041d\u0430 \u0434\u0430\u043d\u043d\u043e\u043c \u044d\u043a\u0440\u0430\u043d\u0435 \u0442\u0430\u043a \u0436\u0435 \u0431\u0443\u0434\u0443\u0442 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0434\u0432\u0435 \u043a\u043d\u043e\u043f\u043a\u0438 \u2014 \u043a\u043d\u043e\u043f\u043a\u0430 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f (Save) \u043d\u043e\u0432\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0438 \u043a\u043d\u043e\u043f\u043a\u0430 \u043e\u0442\u043c\u0435\u043d\u044b (Cancel). \u0412 <code>TeamViewController<\/code> \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u044b-\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u043d\u0430\u0436\u0430\u0442\u0438\u0439 \u043d\u0430 \u044d\u0442\u0438 \u043a\u043d\u043e\u043f\u043a\u0438.<\/p>\n<p>  <code>TeamViewController.h<\/code>  <\/p>\n<pre><code class=\"objectivec\">#import &lt;UIKit\/UIKit.h&gt;  @class MasterViewController;  @interface TeamViewController : UIViewController {    IBOutlet UITextField *name;    IBOutlet UITextField *uniformColor;    NSManagedObject *team;    MasterVIewController *masterController; }  @property (nonatomic, retain) UITextField *name; @property (nonatomic, retain) UITextField *uniformColor; @property (nonatomic, retain) NSManagedObject *team; @property (nonatomic, retain) MasterViewController *masterController;  - (IBAction)save:(id)sender; - (IBAction)cancel:(id)sender; - (id)initWithMasterController:(MasterViewController *)aMasterController team:(NSManagedObject *)aTeam;  @end <\/code><\/pre>\n<p>  \u041e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c <code>TeamViewController.m<\/code>, \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c <code>MasterViewController.h<\/code>, \u0443\u0434\u0430\u043b\u044f\u0435\u043c \u043c\u0435\u0442\u043e\u0434 <code>initWithNibName:<\/code>, \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c @synthesize \u0434\u043b\u044f <code>name<\/code>, <code>team<\/code> \u0438 <code>masterController<\/code>. \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0432\u043e\u0442 \u0442\u0430\u043a\u043e\u0439 \u043c\u0435\u0442\u043e\u0434 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438:  <\/p>\n<pre><code class=\"objectivec\">- (id)initWithMasterController:(MasterController *)aMasterController team:(NSManagedObject *)aTeam {    if((self = [super init])){       self.masterController = aMasterController;       self.team = aTeam;    }     return self; } <\/code><\/pre>\n<p>  \u0412 \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0441\u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0437\u0430\u0445\u043e\u0447\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043d\u043e\u0432\u0443\u044e \u043a\u043e\u043c\u0430\u043d\u0434\u0443, \u0442\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 aTeam \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0432\u0435\u043d nil, \u0438 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 <code>TeamViewController.m<\/code> \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u0432\u0435\u0447\u0430\u0442\u044c \u0437\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043d\u043e\u0432\u043e\u0433\u043e <code>NSManagedObject<\/code> \u043e\u0431\u044a\u0435\u043a\u0442\u0430. \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u0436\u0435, \u0435\u0441\u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0432\u044b\u0431\u0435\u0440\u0435\u0442 \u043e\u0434\u043d\u0443 \u0438\u0437 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u043a\u043e\u043c\u0430\u043d\u0434 \u0434\u043b\u044f \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u0442\u043e \u0437\u0430 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u043e\u043c \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u0437\u0430\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0435 \u043f\u043e\u043b\u044f \u043d\u0430 \u044d\u043a\u0440\u0430\u043d\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0438\u0437 \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 (\u0438\u043c\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0438 \u0446\u0432\u0435\u0442 \u0444\u043e\u0440\u043c\u044b). \u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b \u043c\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0432 \u043c\u0435\u0442\u043e\u0434 <code>viewDidLoad<\/code>:  <\/p>\n<pre><code class=\"objectivec\">- (void)viewDidLoad{    [super viewDidLoad];     if(team != nil){       name.text = [team valueForKey:@&quot;name&quot;];       uniformColor.text = [team valueForKey:@&quot;uniformColor&quot;];    } } <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u043f\u0440\u0438 \u043d\u0430\u0436\u0430\u0442\u0438\u0438 \u043d\u0430 \u043a\u043d\u043e\u043f\u043a\u0438 Save \u0438 Cancel:  <\/p>\n<pre><code class=\"objectivec\">- (IBAction)save:(id)sender {    if(masterController != nil){       if(team != nil){          [team setValue:name.text forKey:@&quot;name&quot;];          [team setValue:uniformColor.text forKey:@&quot;uniformColor&quot;];          [masterController saveContext];       } else {          [masterController insertNewTeamWithName:name.text uniformColor:uniformColor.text];       }    }     [self dismissModalViewControllerAnimated:YES]; } <\/code><\/pre>\n<p>  \u041c\u0435\u0442\u043e\u0434 <code>cancel:<\/code> \u043f\u0440\u043e\u0441\u0442\u043e \u0443\u0431\u0438\u0440\u0430\u0435\u0442 \u043e\u043a\u043d\u043e \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f\/\u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u044b.<br \/>  <code>TeamViewController.m<\/code>  <\/p>\n<pre><code class=\"objectivec\">#import &quot;TeamViewController.h&quot; #import &quot;MasterViewController.h&quot;  @implementation TeamViewController  @synthesize name; @synthesize uniformColor; @synthesize team; @synthesize masterController;  - (id)initWithMasterController:(MasterController *)aMasterController team:(NSManagedObejct *)aTeam {    if((self = [super init])){       self.masterController = aMasterController;       self.team = aTeam;    }     return self; }  - (void)didReceiveMemoryWarning{    [super didReceiveMemoryWarning]; }  #pragma mark - View lifecycle  - (void)viewDidLoad{    [super viewDidLoad];    if(team != nil){       name.text = [team valueForKey:@&quot;name&quot;];       uniformColor.text = [team valueForKey:@&quot;uniformColor&quot;];    } }  - (void)viewDidUnload{    [super viewDidUnload]; }  - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {    return (interfaceOrientation == UIInterfaceOrientationPortrait); }  #pragma mark - Button handlers  - (IBAction)save:(id)sender{    if(masterController != nil){       if(team != nil){          [team setValue:name.text forKey:@&quot;name&quot;];          [team setValue:uniformColor.text forKey:@&quot;uniformColor&quot;];          [masterController saveContext];       } else {          [masterController insertTeamWithName:name.text uniformColor:uniformColor.text];       }    }     [self dismissModalViewControllerAnimated:YES]; }  - (IBAction)cancel:(id)sender{    [self dismissModalViewControllerAnimated:YES]; }  @end <\/code><\/pre>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u043d\u0430\u043f\u0438\u0441\u0430\u043d \u043a\u043e\u0434 \u0434\u043b\u044f \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u0442\u044c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043a \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e \u044d\u0442\u043e\u0433\u043e \u0441\u0430\u043c\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430. \u041e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c <code>TeamViewController.xib<\/code>, \u043e\u043d \u0443 \u043d\u0430\u0441 \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u043f\u0443\u0441\u0442\u043e\u0439 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c. \u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0442\u0443\u0434\u0430 \u0434\u0432\u0435 \u043d\u0430\u0434\u043f\u0438\u0441\u0438, \u0434\u0432\u0430 \u043f\u043e\u043b\u044f \u0432\u0432\u043e\u0434\u0430 \u0442\u0435\u043a\u0441\u0442\u0430 \u0438 \u0434\u0432\u0435 \u043a\u043d\u043e\u043f\u043a, \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u0435\u043c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043a\u043d\u043e\u043f\u043e\u043a \u0441 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u043c\u0438 \u043c\u0435\u0442\u043e\u0434\u0430\u043c\u0438-\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430\u043c\u0438. \u0418\u0442\u043e\u0433\u043e\u0432\u044b\u0439 \u0432\u0438\u0434 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a\u043e\u0439:<br \/>  <img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/16f\/fb9\/5f9\/16ffb95f9962959e4485e32b8bf22742.png\" alt=\"image\"\/><\/p>\n<p>  \u041f\u0435\u0440\u0435\u0434 \u0442\u0435\u043c, \u043a\u0430\u043a \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435, \u0432\u0435\u0440\u043d\u0435\u043c\u0441\u044f \u0432 <code>MasterViewController<\/code> \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043a\u043e\u0434 \u0434\u043b\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u044d\u043a\u0440\u0430\u043d\u0430 \u0441 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0435\u0439 \u043e \u043a\u043e\u043c\u0430\u043d\u0434\u0435. \u041e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0442\u044c \u044d\u043a\u0440\u0430\u043d \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0432 \u0434\u0432\u0443\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445: 1) \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043d\u0430\u0436\u0430\u043b \u043d\u0430 + 2) \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043d\u0430\u0436\u0430\u043b \u043d\u0430 \u043a\u043e\u043c\u0430\u043d\u0434\u0443 \u0438\u0437 \u0441\u043f\u0438\u0441\u043a\u0430. \u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u043d\u0430\u0436\u0430\u0442\u0438\u044f \u043d\u0430 \u043a\u043d\u043e\u043f\u043a\u0443 +. \u041e\u0431\u044a\u044f\u0432\u0438\u0442\u0435 \u043d\u043e\u0432\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u0432 <code>MasterViewController.h<\/code>:  <\/p>\n<pre><code class=\"objectivec\">- (void)showTeamView; <\/code><\/pre>\n<p>  \u0418\u0434\u0435\u043c \u0432 <code>MasterViewController.m<\/code>, \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c <code>TeamViewController.h<\/code> \u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0439 \u0432\u044b\u0448\u0435 \u043c\u0435\u0442\u043e\u0434 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:  <\/p>\n<pre><code class=\"objectivec\">- (void)showTeamView{    TeamViewController *team = [[TeamViewController alloc] initWithMasterController:self team:nil];    [self presentModalViewController:teamViewController animated:YES]; } <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u00ab\u0441\u0432\u044f\u0437\u0430\u0442\u044c\u00bb \u043d\u0430\u0436\u0430\u0442\u0438\u0435 \u043d\u0430 + \u0441 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435\u043c. \u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u0432 <code>viewDidLoad<\/code> \u043c\u0435\u0442\u043e\u0434 \u0438 \u0437\u0430\u043c\u0435\u043d\u044f\u0435\u043c \u0432\u043e\u0442 \u044d\u0442\u043e\u0442 \u043a\u043e\u0434:  <\/p>\n<pre><code class=\"objectivec\">UIBarButtonItem *addButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(insertNewObject)]; <\/code><\/pre>\n<p>  \u043d\u0430 \u044d\u0442\u043e\u0442:  <\/p>\n<pre><code class=\"objectivec\">UIBarButtonItem *addButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(showTeamView)]; <\/code><\/pre>\n<p>  \u041d\u0430 \u0434\u0430\u043d\u043d\u043e\u043c \u044d\u0442\u0430\u043f\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0443\u0436\u0435 \u043c\u043e\u0436\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u044b, \u043d\u043e \u043f\u0435\u0440\u0435\u0434 \u0442\u0435\u043c, \u043a\u0430\u043a \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0441\u0440\u0430\u0437\u0443 \u043a\u043e\u0434 \u0434\u043b\u044f \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u043e\u043c\u0430\u043d\u0434:  <\/p>\n<pre><code class=\"objectivec\">- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath)indexPath{    NSManagedObject *team = [[self fetchedResultsController] objectAtIndexPath:indexPath];    TeamViewController *team = [[TeamViewController alloc] initWithMasterController:self team:team];     [self presentModalViewController:teamViewController animated:YES]; } <\/code><\/pre>\n<p>  \u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435:<br \/>  <img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/0c0\/b0d\/836\/0c0b0d836743b2b61c4a5ad25e763014.png\" alt=\"image\"\/><\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u044b, \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u0445. \u0414\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043a\u043e\u043c\u0430\u043d\u0434, \u0432 \u0441\u043f\u0438\u0441\u043a\u0435 \u043e\u043d\u0438 \u0431\u0443\u0434\u0443\u0442 \u043e\u0442\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u0432 \u043b\u0435\u043a\u0441\u0438\u043a\u043e\u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435.<br \/>  <img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/c61\/ec9\/e8c\/c61ec9e8c89dfad262e85ab4b66eee66.png\" alt=\"image\"\/><br \/>  <img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/432\/6a4\/dc4\/4326a4dc4ffc019904ca973db2143d4b.png\" alt=\"image\"\/><\/p>\n<p>  \u041c\u043e\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0441 \u043f\u0443\u0441\u0442\u044b\u043c\u0438 \u0438\u043c\u0435\u043d\u0430\u043c\u0438 \u0438\u043b\u0438 \u0446\u0432\u0435\u0442\u0430\u043c\u0438 \u0444\u043e\u0440\u043c. \u0415\u0441\u043b\u0438 \u0431\u044b \u044d\u0442\u043e \u0431\u044b\u043b\u043e \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0442\u043e \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0431\u044b\u043b\u043e \u043f\u0440\u0438\u043d\u044f\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043c\u0435\u0440\u044b \u043e\u0442 \u043f\u043b\u043e\u0445\u0438\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445. \u041f\u043e\u0434\u043e\u0431\u043d\u044b\u0439 \u00ab\u043f\u0440\u043e\u043c\u0430\u0445\u00bb \u0441 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445 \u0431\u044b\u043b \u043d\u0430\u043c\u0438 \u043d\u0430\u043c\u0435\u0440\u0435\u043d\u043d\u043e \u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d, \u0438\u0431\u043e \u0432 \u0413\u043b\u0430\u0432\u0435 \u21165 \u043c\u044b \u0438\u0437\u0443\u0447\u0438\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u044b \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0445.<br \/>  \u0417\u0430\u043a\u0440\u043e\u0439\u0442\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 \u0441\u043d\u043e\u0432\u0430\u2026 \u043d\u0430\u0441\u043b\u0430\u0436\u0434\u0430\u0439\u0442\u0435\u0441\u044c \u0432\u0430\u0448\u0438\u043c\u0438 \u0442\u0440\u0443\u0434\u0430\u043c\u0438\u2026 \u043d\u043e, \u043c\u044b \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u043b\u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 \u043a\u043e\u043c\u0430\u043d\u0434\u0430\u043c\u0438, \u0430 \u0441 \u0438\u0433\u0440\u043e\u043a\u0430\u043c\u0438 \u0435\u0449\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u043e\u0438\u0442 \u043f\u043e\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c. \u042d\u0442\u0438\u043c \u043c\u044b \u0438 \u0437\u0430\u0439\u043c\u0435\u043c\u0441\u044f \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u0440\u0430\u0437\u0434\u0435\u043b\u0435.<\/p>\n<h5>\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0438\u0433\u0440\u043e\u043a\u0430\u043c\u0438<\/h5>\n<p>  \u0414\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0438\u0433\u0440\u043e\u043a\u0430\u043c\u0438 \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u0434\u0432\u0430 \u044d\u043a\u0440\u0430\u043d\u0430 \u0438 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430: \u043e\u0434\u0438\u043d \u0434\u043b\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0441\u043f\u0438\u0441\u043a\u0430 \u0438\u0433\u0440\u043e\u043a\u043e\u0432 \u0432 \u043a\u043e\u043c\u0430\u043d\u0434\u0435, \u0430 \u0432\u0442\u043e\u0440\u043e\u0439 \u0434\u043b\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043d\u043e\u0432\u043e\u0433\u043e \u0438\u0433\u0440\u043e\u043a\u0430 \u0438\u043b\u0438 \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0443\u0436\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0433\u043e. \u042d\u0442\u0438 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u044b \u0432 \u0431\u043e\u043b\u044c\u0448\u0435 \u0447\u0430\u0441\u0442\u0438 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0437\u0435\u0440\u043a\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u043a\u043e\u043f\u0438\u044f\u043c\u0438 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u043e\u0432 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043a\u043e\u043c\u0430\u043d\u0434\u0430\u043c\u0438, \u0445\u043e\u0442\u044f \u043e\u043d\u0438 \u0438 \u043d\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442 <code>NSFetchedResultsController<\/code> \u0438 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0439 \u043a\u043e\u0434 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 Core Data, \u0432\u043c\u0435\u0441\u0442\u043e \u044d\u0442\u043e\u0433\u043e \u043e\u043d\u0438 \u0434\u0435\u043b\u0435\u0433\u0438\u0440\u0443\u044e\u0442 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0441 Core Data <code>MasterViewController<\/code>.<\/p>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0441\u043f\u0435\u0440\u0432\u0430 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u0438 \u044d\u043a\u0440\u0430\u043d \u0434\u043b\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0441\u043f\u0438\u0441\u043a\u0430 \u0438\u0433\u0440\u043e\u043a\u043e\u0432 \u043a\u043e\u043c\u0430\u043d\u0434\u044b. \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043d\u043e\u0432\u044b\u0439 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 <code>PlayerListViewController<\/code>, \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0435\u0433\u043e \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u043a\u043b\u0430\u0441\u0441 <code>UITableViewController<\/code> \u0438 \u0441\u043d\u0438\u043c\u0430\u0435\u043c \u0433\u0430\u043b\u043e\u0447\u043a\u0443 \u0441 \u043e\u043f\u0446\u0438\u0438 \u00abWith XIB for user interface\u00bb. \u041e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u0444\u0430\u0439\u043b <code>PlayerListViewController.h<\/code>. \u042d\u0442\u043e\u0442 \u043a\u043b\u0430\u0441\u0441 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0441\u043f\u0438\u0441\u043a\u0430 \u0438\u0433\u0440\u043e\u043a\u043e\u0432 \u043a\u043e\u043c\u0430\u043d\u0434\u044b, \u0430 \u0437\u043d\u0430\u0447\u0438\u0442 \u0432 \u044d\u0442\u043e\u043c \u043a\u043b\u0430\u0441\u0441\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u0430 \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0431\u044a\u0435\u043a\u0442 \u043a\u043e\u043c\u0430\u043d\u0434\u044b. \u0422\u0430\u043a \u0436\u0435, \u0441 \u0443\u0447\u0435\u0442\u043e\u043c \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0434\u0430\u043d\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u0434\u0435\u043b\u0435\u0433\u0438\u0440\u0443\u0435\u0442 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0441 Core Data \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0443 <code>MasterViewController<\/code>, \u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u0430 \u0435\u0449\u0435 \u0438 \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u0441\u0430\u043c \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440. <br \/>  \u041d\u0430 \u044d\u043a\u0440\u0430\u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043a\u043d\u043e\u043f\u043a\u0430 + \u0434\u043b\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043d\u043e\u0432\u043e\u0433\u043e \u0438\u0433\u0440\u043e\u043a\u0430. \u041e\u0431\u044a\u044f\u0432\u0438\u043c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u043c\u0435\u0442\u043e\u0434-\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043d\u0430\u0436\u0430\u0442\u0438\u044f.<\/p>\n<p>  <b>PlayerListViewController.h<\/b>  <\/p>\n<pre><code class=\"objectivec\">#import &lt;UIKit\/UIKit.h&gt;  @class MasterViewController;  @interface PlayerListViewController : UITableVIewController {    NSManagedObject *team;    MasterViewController *masterViewController; }  @property (nonatomic, retain) NSManagedObject *team; @property (nonatomic, retain) MasterViewController *masterController;  - (id)initWithMasterController:(MasterViewController *)aMasterController team:(NSManagedObject *)aTeam; - (void)showPlayerView; - (NSArray *)sortPlayers;  @end <\/code><\/pre>\n<p>  \u041e\u0442\u043a\u0440\u043e\u0439\u0442\u0435 \u0444\u0430\u0439\u043b <code>PlayerListViewController.m<\/code> \u0438 \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0439\u0442\u0435 <code>MasterVIewController.h<\/code>, \u0441\u0438\u043d\u0442\u0435\u0437\u0438\u0440\u0443\u0439\u0442\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 <code>team<\/code> \u0438 <code>masterController<\/code>. \u0418\u0437\u043c\u0435\u043d\u0438\u0442\u0435 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 <code>initWithStyle:<\/code> \u043d\u0430 <code>initWithMasterController:<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0434\u0432\u0430 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:  <\/p>\n<pre><code class=\"objectivec\">- (id)initWithMasterController:(MasterVIewController *)aMasterVIewController team:(NSManagedObject *)aTeam {    if((self = [super init])){       self.masterController = aMasterController;       self.team = aTeam;    }    return self; } <\/code><\/pre>\n<p>  \u0421\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043c\u0435\u0442\u043e\u0434 <code>viewDidLoad<\/code> \u0438\u0437\u043c\u0435\u043d\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:  <\/p>\n<pre><code class=\"objectivec\">- (void)viewDidLoad{    [super viewDidLoad];     self.title = @&quot;Player&quot;;     UIBarButtonItem *addButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(showPlayerView)];    self.navigationItem.rightBarButtonItem = addButton; } <\/code><\/pre>\n<p>  \u0410 \u043c\u0435\u0442\u043e\u0434 <code>showPlayerView<\/code> \u043f\u043e\u043a\u0430 \u043e\u0441\u0442\u0430\u0432\u0438\u043c \u043f\u0443\u0441\u0442\u044b\u043c:  <\/p>\n<pre><code class=\"objectivec\">- (void)showPlayerView{ } <\/code><\/pre>\n<p>  \u041f\u043e\u0434\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u0438\u0440\u0443\u0435\u043c \u043c\u0435\u0442\u043e\u0434 viewWillAppear: \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:  <\/p>\n<pre><code class=\"objectivec\">- (void)viewWillAppear:(BOOL)animated{    [super viewWillAppear:animated];    [self.tableView reloadData]; } <\/code><\/pre>\n<p>  \u0421\u043f\u0438\u0441\u043e\u043a \u0438\u0433\u0440\u043e\u043a\u043e\u0432 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d \u0432 \u0430\u043b\u0444\u0430\u0432\u0438\u0442\u043d\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435 \u0432 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u0441\u0435\u043a\u0446\u0438\u0438 (\u0440\u0430\u0437\u0434\u0435\u043b\u0435). \u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0432\u0441\u0435\u0445 \u0438\u0433\u0440\u043e\u043a\u043e\u0432 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434 <code>valueForKey:@&quot;players&quot;<\/code> \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043a\u043e\u043c\u0430\u043d\u0434\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u0435\u0440\u043d\u0435\u0442 \u043d\u0430\u043c <code>NSSet*<\/code> \u0438\u0433\u0440\u043e\u043a\u043e\u0432. \u041d\u0438\u0436\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u043a\u043e\u0434 \u0434\u043b\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u044b:  <\/p>\n<pre><code class=\"objectivec\">- (NSUInteger)numberOfSectionInTableView:(UITableView *)tableView {    return 1; }  - (NSInteger)tableView:(UITableVIew *)tableView numberOfRowsInSection:(NSInteger)section {    return [(NSSet *)[team valueForKey:@&quot;players&quot;] count]; }  - (UITableViewCell *)tableView:(UITableVIew *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {    static NSString *CellIdentifier = @&quot;PlayerCell&quot;;     UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];    if(cell == nil){       cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier];    }     NSManagedObject *player = [[self sortPlayers] objectAtIndex:indexPath.row];    cell.textLabel.text = [NSString stringWithFormat:@&quot;%@ %@&quot;, [[player valueForKey:@&quot;firstName&quot;] description], [[player valueForKey:@&quot;lastName&quot;] description]];    cell.detailTextLabel.text = [[player valueForKey:@&quot;email&quot;] description];     return cell; } <\/code><\/pre>\n<p>  \u0412\u044b\u0448\u0435 \u0435\u0441\u0442\u044c \u0432\u044b\u0437\u043e\u0432 \u043c\u0435\u0442\u043e\u0434\u0430 <code>sortPlayers<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043e\u0442\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 \u0438\u0433\u0440\u043e\u043a\u043e\u0432:  <\/p>\n<pre><code class=\"objectivec\">- (NSArray *)sortPlayers{    NSSortDescriptor *sortLastNameDescriptor = [[NSSortDescriptor alloc] initWithKey:@&quot;lastName&quot; ascending:YES];    NSArray *sortDescriptors = [NSArray arrayWithObjects:sortLastNameDescriptor, nil];    return [[(NSSet *)[team valueForKey:@&quot;players&quot;] allObjects] sortedArrayUsingDescriptors:sortDescriptors]; } <\/code><\/pre>\n<p>  \u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0438\u0433\u0440\u043e\u043a\u043e\u0432 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0432\u0435\u0440\u043d\u0435\u043c\u0441\u044f \u0432 MasterViewController.m \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043c\u0435\u0442\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u043d\u0430\u0436\u0430\u0442\u0438\u0435 \u043d\u0430 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0430\u043a\u0441\u0435\u0441\u0441\u0443\u0430\u0440 (\u0441\u0438\u043d\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u044f\u0447\u0435\u0439\u043a\u0438):  <\/p>\n<pre><code class=\"objectivec\">- (void)tableView:(UITableVIew *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath{    NSManagedObject *team = [self.fetchedResultsController objectAtIndexPath:indexPath];    PlayerListViewController *playerListViewController = [[PlayerListViewController alloc] initWithMasterController:self team:team];    [self.navigationController pushViewController:playerListViewController animated:YES]; } <\/code><\/pre>\n<p>  \u0414\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0438\u043c\u043f\u043e\u0440\u0442 <code>PlayerListViewController.h<\/code> \u0432 <code>MasterViewController.m<\/code>. \u0422\u0435\u043f\u0435\u0440\u044c \u0441\u043e\u0431\u0435\u0440\u0435\u043c \u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435. \u0412 \u0441\u043f\u0438\u0441\u043a\u0435 \u043a\u043e\u043c\u0430\u043d\u0434 \u043c\u044b \u0432\u0438\u0434\u0438\u043c \u0440\u0430\u043d\u0435\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0430\u043c\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u044b, \u043f\u0440\u0438 \u043d\u0430\u0436\u0430\u0442\u0438\u0438 \u043d\u0430 \u0430\u043a\u0441\u0435\u0441\u0441\u0443\u0430\u0440-\u043a\u043d\u043e\u043f\u043a\u0443 \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0441\u043f\u0438\u0441\u043e\u043a \u0438\u0433\u0440\u043e\u043a\u043e\u0432 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u044b (\u043f\u043e\u043a\u0430 \u0441\u043f\u0438\u0441\u043a\u0438 \u0438\u0433\u0440\u043e\u043a\u043e\u0432 \u043f\u0443\u0441\u0442\u044b, \u0438\u0431\u043e \u043c\u044b \u043d\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043b\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043d\u043e\u0432\u043e\u0433\u043e \u0438\u0433\u0440\u043e\u043a\u0430).<br \/>  <img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/f9d\/bc3\/155\/f9dbc3155b565dd77a3321328fc4d7f6.png\" alt=\"image\"\/><\/p>\n<h5>\u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435, \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0438\u0433\u0440\u043e\u043a\u043e\u0432<\/h5>\n<p>  \u041f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0443\u0436\u0435 \u043f\u043e\u0447\u0442\u0438 \u0433\u043e\u0442\u043e\u0432\u043e; \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435, \u0447\u0442\u043e \u0441\u0442\u043e\u0438\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c, \u0442\u0430\u043a \u044d\u0442\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435\/\u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\/\u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0438\u0433\u0440\u043e\u043a\u043e\u0432. <br \/>  \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043d\u043e\u0432\u044b\u0439 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 (<code>UIViewController<\/code>) c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u043c XIB\u043e\u043c \u0438 \u043d\u0430\u0437\u043e\u0432\u0435\u043c \u0435\u0433\u043e <code>PlayerViewController<\/code>. \u041e\u043d \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0445\u043e\u0436 \u043d\u0430 <code>TeamViewController<\/code>, \u043d\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0442\u0440\u0438 \u043f\u043e\u043b\u044f: <code>lastName<\/code>, <code>firstName<\/code> \u0438 <code>email<\/code>. \u041a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u0442\u0430\u043a \u0436\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 <code>MasterViewController<\/code> \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0438\u043c\u0435\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0435 \u0440\u0430\u043d\u0435\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 Core Data. \u0422\u0430\u043a \u0436\u0435 \u0431\u0443\u0434\u0443\u0442 \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0435\u0449\u0435 \u0434\u0432\u0430 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430: \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0438\u0433\u0440\u0430\u0435\u0442 \u0438\u0433\u0440\u043e\u043a \u0438 \u0441\u0430\u043c \u0438\u0433\u0440\u043e\u043a. \u0415\u0441\u043b\u0438 \u043e\u0431\u044a\u0435\u043a\u0442 \u0438\u0433\u0440\u043e\u043a\u0430 \u0440\u0430\u0432\u0435\u043d <code>nil<\/code>, \u0442\u043e <code>PlayerViewController<\/code> \u0437\u043d\u0430\u0435\u0442, \u0447\u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043d\u043e\u0432\u043e\u0433\u043e \u0438\u0433\u0440\u043e\u043a\u0430, \u0432 \u043f\u0440\u043e\u0442\u0438\u0432\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u2014 \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0433\u0440\u043e\u043a\u0430. \u041d\u0430 \u044d\u043a\u0440\u0430\u043d\u0435 \u0443 \u043d\u0430\u0441 \u0431\u0443\u0434\u0435\u0442 \u0442\u0440\u0438 \u043a\u043d\u043e\u043f\u043a\u0438: \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c, \u043e\u0442\u043c\u0435\u043d\u0430 \u0438 \u0443\u0434\u0430\u043b\u0438\u0442\u044c. \u041f\u0440\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0435 \u043d\u0430 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0438\u0433\u0440\u043e\u043a\u0430 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0442\u044c \u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0438\u0435 \u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0432 \u0432\u0438\u0434\u0435 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f <code>UIActionSheeta<\/code>, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e, \u0447\u0442\u043e\u0431\u044b <code>PlayerViewController<\/code> \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u043b \u043c\u0435\u0442\u043e\u0434\u044b \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430 <code>UIActionSheetDelegate<\/code>. <\/p>\n<p>  <b>PlayerViewController.h<\/b>  <\/p>\n<pre><code class=\"objectivec\">#import &lt;UIKit\/UIKit.h&gt;  @class MasterViewController;  @interface PlayerViewController : UIViewController &lt;UIActionSheetDelegate&gt; {    IBOutlet UITextField *firstName;    IBOutlet UITextField *lastName;    IBOutlet UITextField *email;     NSManagedObject *team;    NSManagedObject *player;     MasterViewController *masterViewController; }  @property (nonatomic, retain) UITextField *firstName; @property (nonatomic, retain) UITextField *lastName; @property (nonatomic, retain) UITextField *email; @property (nonatomic, retain) NSManagedObject *team; @property (nonatomic, retain) NSManagedObject *player; @property (nonatomic, retain) MasterViewController *masterController;  - (IBAction)save:(id)sender; - (IBAction)cancel:(id)sender; - (IBAction)confirmDelete:(id)sender; - (id)initWithMasterController:(MasterViewController *)aMasterController team:(NSManagedObject *)aTeam player:(NSManagedObject *)aPlayer;  @end <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043e\u0442\u043a\u0440\u043e\u0439\u0442\u0435 <code>PlayerViewController.m<\/code>, \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0439\u0442\u0435 <code>MasterViewController.h<\/code> \u0438 \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 <code>@synthesize<\/code> \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u0441\u0432\u043e\u0439\u0441\u0442\u0432 \u0438\u0437 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430. \u0414\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u043c\u0435\u0442\u043e\u0434 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0432 <code>PlayerVIewController.m<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043a\u043b\u0430\u0441\u0441\u0430 <code>MasterViewController<\/code>, \u043a\u043e\u043c\u0430\u043d\u0434\u0443 \u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043e\u0431\u044a\u0435\u043a\u0442 \u0438\u0433\u0440\u043e\u043a\u0430.  <\/p>\n<pre><code class=\"objectivec\">- (id)initWithMasterController:(MasterViewController *)aMasterController team:(NSManagedObject *)aTeam player:(NSManagedObject *)aPlayer{    if((self = [super init])){       self.masterController = aMasterController;       self.team = team;       self.player = player;    }     return self; } <\/code><\/pre>\n<p>  \u0412 \u043c\u0435\u0442\u043e\u0434 <code>viewDidLoad<\/code> \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043a\u043e\u0434 \u0434\u043b\u044f \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0445 \u043f\u043e\u043b\u0435\u0439 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0438\u0433\u0440\u043e\u043a\u0430, \u0435\u0441\u043b\u0438 \u043e\u043d \u043d\u0435 \u0440\u0430\u0432\u0435\u043d <code>nil<\/code>.  <\/p>\n<pre><code class=\"objectivec\">- (void)viewDidLoad {    [super viewDidLoad];    if(player != nil){       firstName.text = [player valueForKey:@&quot;firstName&quot;];       lastName.text = [player valueForKey:@&quot;lastName&quot;];       email.text = [player valueForKey:@&quot;email&quot;];    } } <\/code><\/pre>\n<p>  \u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043d\u0430\u0448\u0438\u043c \u0448\u0430\u0433\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043c\u0435\u0442\u043e\u0434\u043e\u0432-\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 \u043d\u0430\u0436\u0430\u0442\u0438\u0439 \u043d\u0430 \u043a\u043d\u043e\u043f\u043a\u0438:  <\/p>\n<pre><code class=\"objectivec\">- (IBAction)save:(id)sender{    if(masterController != nil){       if(player != nil){          [player setValue:firstName.text forKey:@&quot;firstName&quot;];          [player setValue:lastName.text forKey:@&quot;lastName&quot;];          [player setValue:email.text forKey:@&quot;email&quot;];       } else {          [masterController insertPlayerWithTeam:team firstName:firstName.text lastName:lastName.text email:email.text];       }    }     [self dismissModelViewControllerAnimated:YES]; }  - (IBAction)cancel:(id)sender{    [self dismissModalViewControllerAnimated:YES]; } <\/code><\/pre>\n<p>  \u041c\u0435\u0442\u043e\u0434\u0430 <code>insertPlayerWithTeam:firstName:lastName:email:<\/code> \u0432 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0435 <code>MasterViewController<\/code> \u043f\u043e\u043a\u0430 \u043d\u0435\u0442, \u043d\u043e \u043c\u044b \u0435\u0433\u043e \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0431\u0443\u043a\u0432\u0430\u043b\u044c\u043d\u043e \u0447\u0435\u0440\u0435\u0437 \u043f\u0430\u0440\u0443 \u043c\u0438\u043d\u0443\u0442. \u00a0\u0421\u043f\u0435\u0440\u0432\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c <code>confirmDelete:<\/code> \u043c\u0435\u0442\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u043d\u0430\u0436\u0430\u0442\u0438\u0438 \u043d\u0430 \u043a\u043d\u043e\u043f\u043a\u0443 \u00abDelete\u00bb(\u0423\u0434\u0430\u043b\u0438\u0442\u044c). \u042d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0441\u0440\u0430\u0437\u0443 \u0443\u0434\u0430\u043b\u044f\u0442\u044c \u0438\u0433\u0440\u043e\u043a\u0430, \u0430 \u043e\u043d \u0437\u0430\u043f\u0440\u043e\u0441\u0438\u0442 \u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0438\u044f \u043d\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f (\u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0445 \u043d\u0430\u0436\u0430\u0442\u0438\u0439 \u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0439 \u0438\u0433\u0440\u043e\u043a\u043e\u0432). \u0412\u043e\u0442 \u043a\u0430\u043a \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u043c\u0435\u0442\u043e\u0434 <code>confirmDelete:<\/code>:  <\/p>\n<pre><code class=\"objectivec\">- (IBAction)confirmDelete:(id)sender{    if(player != nil){       UIActionSheet *confirm = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:@&quot;Cancel&quot; destructiveButtonTitle:@&quot;Delete Player&quot; otherButtonTitles:nil];       confirm.actionSheetStyle = UIActionSheetStyleBlackTranslucent;       [confirm showInView:self.view];    } } <\/code><\/pre>\n<p>  \u0414\u0435\u043b\u0435\u0433\u0430\u0442\u043e\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u044b\u0435 \u0432 <code>UIActionSheet\u0435<\/code> \u0431\u0443\u0434\u0435\u0442 \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u043a\u043b\u0430\u0441\u0441. \u041f\u0440\u0438 \u043d\u0430\u0436\u0430\u0442\u0438\u0438 \u043d\u0430 \u043a\u043d\u043e\u043f\u043a\u0438 <code>UIActionSheet\u0430<\/code> \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u043c\u0435\u0442\u043e\u0434 <code>clickedButtonAtIndex:<\/code>, \u0430 \u0437\u043d\u0430\u0447\u0438\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0435\u0433\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c. \u0412 \u043c\u0435\u0442\u043e\u0434\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043d\u0430 \u0442\u043e \u043a\u0430\u043a\u0430\u044f \u043a\u043d\u043e\u043f\u043a\u0430 \u0431\u044b\u043b\u0430 \u043d\u0430\u0436\u0430\u0442\u0430 \u0438, \u0435\u0441\u043b\u0438 \u043a\u043d\u043e\u043f\u043a\u0430 Delete, \u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0437\u0432\u0430\u043d \u043c\u0435\u0442\u043e\u0434 (\u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0442\u0430\u043a \u0436\u0435 \u043f\u043e\u0442\u043e\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c) \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u0438\u0433\u0440\u043e\u043a\u0430:  <\/p>\n<pre><code class=\"objectivec\">- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{    if(buttonIndex == 0 && masterController != nil){       [masterController deletePlayer:player];       [self dismissModalViewControllerAnimated:YES];    } } <\/code><\/pre>\n<p>  \u0412\u0435\u0440\u043d\u0435\u043c\u0441\u044f \u0442\u0435\u043f\u0435\u0440\u044c \u043a <code>MasterViewController.h<\/code> \u0438 \u043e\u0431\u044a\u044f\u0432\u0438\u043c \u0434\u0432\u0430 \u043c\u0435\u0442\u043e\u0434\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u0435\u0449\u0435 \u043d\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u043b\u0438, \u043d\u043e \u0443\u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438:  <\/p>\n<pre><code class=\"objectivec\">- (void)insertPlayerWithTeam:(NSManagedObject *)team firstName:(NSString *)firstName lastName:(NSString *)lastName email:(NSString *)email; - (void)deletePlayer:(NSManagedObject *)player; <\/code><\/pre>\n<p>  \u041e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u0442\u0435\u043f\u0435\u0440\u044c <code>MasterViewController.m<\/code> \u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u043c\u0435\u0442\u043e\u0434\u044b:  <\/p>\n<pre><code class=\"objectivec\">- (void)insertPlayerWithTeam:(NSManagedObject *)team firstName:(NSString *)firstName lastName:(NSString *)lastName email:(NSString *)email{    NSManagedObjectContext *context = [self.fetchedResultsController managedObjectContext];    NSManagedObject *player = [NSEntityDescription insertNewObjectForEntityForName:@&quot;Player&quot; inManagedObjectContext:context];     [player setValue:firstName forKey:@&quot;firstName&quot;];    [player setValue:lastName forKey:@&quot;lastName&quot;];    [player setValue:email forKey:@&quot;email&quot;];    [player setValue:team forKey:@&quot;team&quot;];     [self saveContext]; }  - (void)deletePlayer:(NSManagedObject *)player{    NSManagedObjectContext *context = [self.fetchedResultsController managedObjectContext];    [context deleteObject:player];    [self saveContext]; } <\/code><\/pre>\n<p>  \u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u043c \u0448\u0430\u0433\u043e\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0433\u043e \u044d\u043a\u0440\u0430\u043d\u0430 \u0434\u043b\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f\/\u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438\u0433\u0440\u043e\u043a\u0430. \u0412\u044b\u0431\u0435\u0440\u0438\u0442\u0435 <code>PlayerViewController.xib<\/code>, \u043f\u0440\u0438\u0432\u0435\u0434\u0438\u0442\u0435 \u0435\u0433\u043e \u043a \u0442\u0430\u043a\u043e\u043c\u0443 \u0432\u0438\u0434\u0443, \u043a\u0430\u043a \u043d\u0430 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0435 \u043d\u0438\u0436\u0435 \u0438 \u0441\u043e\u0435\u0434\u0438\u043d\u0438\u0442\u0435 \u0432\u0441\u0435 Action \u0441 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u043c\u0438 \u043a\u043d\u043e\u043f\u043a\u0430\u043c\u0438.<br \/>  <img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/b9d\/5b1\/ea0\/b9d5b1ea098e9f043571e4299f819542.png\" alt=\"image\"\/><\/p>\n<p>  \u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043e\u0442\u043e\u0431\u0440\u0430\u0437\u0438\u0442\u044c \u044d\u0442\u043e\u0442 \u044d\u043a\u0440\u0430\u043d \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u0435\u0440\u043d\u0443\u0442\u044c\u0441\u044f \u043a \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043c\u0435\u0442\u043e\u0434\u0430 <code>showPlayerView:<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0440\u0430\u043d\u0435\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438. \u0418\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0439\u0442\u0435 \u0432 <code>PlayerListViewController.m<\/code> \u0444\u0430\u0439\u043b <code>PlayerViewController.h<\/code>.   <\/p>\n<pre><code class=\"objectivec\">- (void)showPlayerVIew{    PlayerVIewController *playerViewController = [[PlayerVIewController alloc] initWithMasterController:masterController team:team player:nil];    [self presentModalViewController:playerVIewController animated:YES]; } <\/code><\/pre>\n<p>  \u041d\u0430\u043c \u0442\u0430\u043a\u0436\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u043d\u0430\u0436\u0430\u0442\u0438\u044f \u043d\u0430 \u044f\u0447\u0435\u0439\u043a\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0441\u043f\u0438\u0441\u043a\u0430 \u0438\u0433\u0440\u043e\u043a\u043e\u0432. \u041d\u0430\u0445\u043e\u0434\u0438\u043c \u0432 <code>PlayerListViewController.m<\/code> \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 <code>didSelectRowAtIndexPath:<\/code> \u0438 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u043c \u0435\u0433\u043e \u043a \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c\u0443 \u0432\u0438\u0434\u0443:  <\/p>\n<pre><code class=\"objectivec\">- (void)tableView:(UITableVIew *)tableVIew didSelectRowAtIndexPath:(NSIndexPath *)indexPath{    NSManagedObject *player = [[self sortPlayers] objectAtIndex:indexPath.row];    PlayerViewController *playerViewController = [[PlayerVIewController alloc] initWithMasterController:masterController team:team player:player];    [self presentModalVIewController:playerViewController animated:YES]; } <\/code><\/pre>\n<p>  \u041d\u0430 \u044d\u0442\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u0430\u043c\u0438 \u0438 \u0438\u0433\u0440\u043e\u043a\u0430\u043c\u0438 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0430. \u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435. \u0414\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0438\u0433\u0440\u043e\u043a\u043e\u0432, \u0443\u0434\u0430\u043b\u0438\u0442\u0435 \u0438\u0433\u0440\u043e\u043a\u043e\u0432, \u0443\u0434\u0430\u043b\u0438\u0442\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0441 \u0438\u0433\u0440\u043e\u043a\u0430\u043c\u0438.<\/p>\n<p>  \u041e\u0441\u0442\u0430\u0432\u0448\u0438\u0435\u0441\u044f \u0441\u0435\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0430. \u0421\u043a\u043e\u0440\u043e \u0431\u0443\u0434\u0443\u0442.  <\/p>\n<h5>\u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430<\/h5>\n<p>  <\/p>\n<h5>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 (In-memory persistent store)<\/h5>\n<p>  <\/p>\n<h5>\u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430<\/h5>\n<p>  <\/p>\n<h5>\u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c\u043e\u0433\u043e \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430<\/h5>\n<p>  <\/p>\n<h5>\u041e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u0435\u043d\u0438\u0435 \u043c\u0430\u043f\u043f\u0438\u043d\u0433\u0430 \u043c\u0435\u0436\u0434\u0443 NSManagedObject \u0438 NSAtomicStoreCacheNode<\/h5>\n<p>  <\/p>\n<h5>\u0421\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445<\/h5>\n<p>  <\/p>\n<h5>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c\u043e\u0433\u043e (\u043a\u0430\u0441\u0442\u043e\u043c\u043d\u043e\u0433\u043e) \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430<\/h5>\n<p>  <\/p>\n<h5>\u0427\u0442\u043e \u043d\u0430\u0441\u0447\u0435\u0442 XML-\u0442\u0438\u043f\u0430 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430?<\/h5>\n<p>  <\/p>\n<h5>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h5>\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\/192960\/\"> http:\/\/habrahabr.ru\/post\/192960\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">   \t\u0425\u0430\u0431\u0440\u0430\u043b\u044e\u0434\u0438, \u0434\u043e\u0431\u0440\u044b\u0439 \u0434\u0435\u043d\u044c!<br \/>  \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u0445\u043e\u0447\u0443 \u043d\u0430\u0447\u0430\u0442\u044c \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0440\u044f\u0434\u0430 \u043b\u0435\u043a\u0446\u0438\u0439 \u0441 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u043c\u0438 \u0437\u0430\u0434\u0430\u043d\u0438\u044f\u043c\u0438 \u043f\u043e \u043a\u043d\u0438\u0433\u0435 \u041c\u0438\u0445\u0430\u0435\u043b\u044f \u041f\u0440\u0438\u0432\u0430\u0442\u0430 \u0438 \u0420\u043e\u0431\u0435\u0440\u0442\u0430 \u0412\u0430\u0440\u043d\u0435\u0440\u0430 \u00abPro Core Data for iOS\u00bb, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u043e\u0436\u0435\u0442\u0435 \u043a\u0443\u043f\u0438\u0442\u044c \u043f\u043e <a href=\"http:\/\/www.apress.com\/9781430236566\">\u044d\u0442\u043e\u0439<\/a> \u0441\u0441\u044b\u043b\u043a\u0435. \u041a\u0430\u0436\u0434\u0430\u044f \u0433\u043b\u0430\u0432\u0430 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0442\u0435\u043e\u0440\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u0438 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u0447\u0430\u0441\u0442\u044c.<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage3\/f39\/8f2\/7fe\/f398f27fe69976e2305f4055fc97c9b2.png\"\/><\/p>\n<p>  \u0421\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0435:  <\/p>\n<ul>\n<li> <a href=\"http:\/\/habrahabr.ru\/post\/191334\/\">\u0413\u043b\u0430\u0432\u0430 \u21161. \u041f\u0440\u0438\u0441\u0442\u0443\u043f\u0430\u0435\u043c<\/a> (<a href=\"http:\/\/habrahabr.ru\/post\/191472\/\">\u041f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0447\u0430\u0441\u0442\u044c<\/a>) <\/li>\n<li> <a href=\"http:\/\/habrahabr.ru\/post\/191580\/\">\u0413\u043b\u0430\u0432\u0430 \u21162. \u0423\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u043c Core Data<\/a> (<a href=\"http:\/\/habrahabr.ru\/post\/192090\/\">\u041f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0447\u0430\u0441\u0442\u044c<\/a>)<\/li>\n<li> <a href=\"http:\/\/habrahabr.ru\/post\/192960\/\">\u0413\u043b\u0430\u0432\u0430 \u21163. \u0425\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445: SQLite \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b<\/a><\/li>\n<li> \u0413\u043b\u0430\u0432\u0430 \u21164. \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0445<\/li>\n<li> \u0413\u043b\u0430\u0432\u0430 \u21165. \u0420\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u0441 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0445<\/li>\n<li> \u0413\u043b\u0430\u0432\u0430 \u21166. \u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0438\u0440\u0443\u044e\u0449\u0438\u0445 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432<\/li>\n<li> \u0413\u043b\u0430\u0432\u0430 \u21167. \u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438<\/li>\n<li> \u0413\u043b\u0430\u0432\u0430 \u21168. \u0423\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0432\u0435\u0440\u0441\u0438\u044f\u043c\u0438 \u0438 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438<\/li>\n<li> \u0413\u043b\u0430\u0432\u0430 \u21169. \u0423\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u043c\u0438 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c NSFetchedResultsController<\/li>\n<li> \u0413\u043b\u0430\u0432\u0430 \u211610. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 Core Data \u0432 \u043f\u0440\u043e\u0434\u0432\u0438\u043d\u0443\u0442\u044b\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u0445<\/li>\n<\/ul>\n<p>  <\/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-192960","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/192960","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=192960"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/192960\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=192960"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=192960"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=192960"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}