{"id":191334,"date":"2013-08-26T02:25:03","date_gmt":"2013-08-25T22:25:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=191334"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=191334","title":{"rendered":"<span class=\"post_title\">Pro Core Data for iOS. \u0413\u043b\u0430\u0432\u0430 \u21161. \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 <b>\u0432\u043e\u043b\u044c\u043d\u044b\u0439<\/b> \u043f\u0435\u0440\u0435\u0432\u043e\u0434 \u043a\u043d\u0438\u0433\u0438 \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 \u0441\u043a\u0430\u0447\u0430\u0442\u044c \u043f\u043e <a href=\"http:\/\/it-ebooks.info\/book\/1843\/\">\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:\/\/habr.habrastorage.org\/post_images\/884\/2d0\/182\/8842d018201f3945800282b64f1d7221.jpg\" alt=\"image\"\/><\/p>\n<p>  \u0421\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0435:  <\/p>\n<ul>\n<li> \u0413\u043b\u0430\u0432\u0430 \u21161. \u041f\u0440\u0438\u0441\u0442\u0443\u043f\u0430\u0435\u043c (\u041f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0447\u0430\u0441\u0442\u044c) <\/li>\n<li> \u0413\u043b\u0430\u0432\u0430 \u21162. \u0423\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u043c Core Data<\/li>\n<li> \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<\/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<h4>\u041f\u0440\u0438\u0441\u0442\u0443\u043f\u0430\u0435\u043c<\/h4>\n<p>  <\/p>\n<h5>\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 Core Data?<\/h5>\n<p>  \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u044b \u0434\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0441\u0432\u043e\u0438\u0445 \u0437\u0430\u0434\u0430\u0447, \u043b\u044e\u0434\u0438 \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u044e\u0442, \u0447\u0442\u043e \u0432\u043d\u0435\u0441\u0435\u043d\u043d\u044b\u0435 \u0438\u043c\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u044b. \u0421\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u0438\u0433\u0440\u0430\u0435\u0442 \u0432\u0430\u0436\u043d\u0443\u044e \u0440\u043e\u043b\u044c \u0432 \u043e\u0444\u0438\u0441\u043d\u044b\u0445 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u044b\u0445 \u043f\u0430\u043a\u0435\u0442\u0430\u0445, \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0445 \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u0430\u0445, \u0438\u0433\u0440\u0430\u0445, \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430\u0445 \u0438 \u0442\u0434. \u0411\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u043e\u0433\u043e \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0435\u043d\u0438\u044f \u043d\u0443\u0436\u0434\u0430\u0435\u0442\u0441\u044f \u0432 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0432\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0440\u0430\u0431\u043e\u0442\u044b, \u043d\u043e \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0436\u0435 \u0435\u0441\u0442\u044c \u0438 \u0442\u0430\u043a\u043e\u0435 \u041f\u041e, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432 \u044d\u0442\u043e\u043c \u043d\u0435 \u043d\u0443\u0436\u0434\u0430\u0435\u0442\u0441\u044f \u2014 \u043a\u0430\u043b\u044c\u043a\u0443\u043b\u044f\u0442\u043e\u0440\u044b, \u043d\u043e\u0432\u043e\u0441\u0442\u043d\u044b\u0435 \u043b\u0435\u043d\u0442\u044b, \u0431\u0443\u0434\u0438\u043b\u044c\u043d\u0438\u043a\u0438, \u0432\u0438\u0434\u0436\u0435\u0442\u044b \u043e \u043f\u043e\u0433\u043e\u0434\u0435.<br \/>  \u041f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043c\u043e\u0436\u043d\u043e \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 iDevice, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u0440\u0438\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0432\u0430\u0436\u043d\u044b\u043c \u043f\u0440\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u043f\u0440\u043e\u0434\u0432\u0438\u043d\u0443\u0442\u044b\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439.<\/p>\n<p>  Apple \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0433\u0438\u0431\u043a\u0438\u0439 \u0444\u0440\u044d\u0439\u043c\u0432\u043e\u0440\u043a \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0445\u0440\u0430\u043d\u0438\u043c\u044b\u043c\u0438 \u043d\u0430 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0435 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u2014 Core Data. \u041a\u043e\u043d\u0435\u0447\u043d\u043e \u0436\u0435 Core Data \u043d\u0435 \u043f\u0430\u043d\u0430\u0446\u0435\u044f \u0438 \u0435\u0441\u0442\u044c \u0434\u0440\u0443\u0433\u0438\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u043b\u0443\u0447\u0448\u0435 \u043f\u043e\u0434\u043e\u0439\u0442\u0438 \u043f\u0440\u0438 \u0440\u0435\u0448\u0435\u043d\u0438\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0445 \u0437\u0430\u0434\u0430\u0447, \u043d\u043e \u0443\u0436 \u043e\u0447\u0435\u043d\u044c \u0445\u043e\u0440\u043e\u0448\u043e \u0438 \u043a\u0440\u0430\u0441\u0438\u0432\u043e Core Data \u0432\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432 Cocoa Touch. \u0411\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u0434\u0435\u0442\u0430\u043b\u0435\u0439 \u043f\u043e \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0445 Core Data \u0441\u043a\u0440\u044b\u0432\u0430\u0435\u0442, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044f \u0432\u0430\u043c \u0441\u043a\u043e\u043d\u0446\u0435\u043d\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u0442\u043e\u043c, \u0447\u0442\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u0432\u0430\u0448\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0432\u0435\u0441\u0435\u043b\u044b\u043c, \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u043c \u0438 \u0443\u0434\u043e\u0431\u043d\u044b\u043c \u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438.<\/p>\n<p>  \u041d\u0435 \u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e Core Data \u043c\u043e\u0436\u0435\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0440\u0435\u043b\u044f\u0446\u0438\u043e\u043d\u043d\u043e\u0439 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432\u0440\u043e\u0434\u0435 SQLite, Core Data \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0421\u0423\u0411\u0414. \u041f\u043e-\u043f\u0440\u0430\u0432\u0434\u0435 Core Data \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430 \u043c\u043e\u0436\u0435\u0442 \u0432\u043e\u043e\u0431\u0449\u0435 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0440\u0435\u043b\u044f\u0446\u0438\u043e\u043d\u043d\u044b\u0435 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445. Core Data \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0447\u0435\u043c-\u0442\u043e \u0432\u0440\u043e\u0434\u0435 Hibernate, \u0445\u043e\u0442\u044f \u0438 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 ORM. Core Data \u0441\u043a\u043e\u0440\u0435\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0431\u043e\u043b\u043e\u0447\u043a\u043e\u0439\/\u0444\u0440\u044d\u0439\u043c\u0432\u043e\u0440\u043a\u043e\u043c \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044f\u043c\u0438 \u0438 \u0438\u0445 \u0441\u0432\u044f\u0437\u044f\u043c\u0438 (\u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044f\u043c\u0438 \u043a \u0434\u0440\u0443\u0433\u0438\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438), \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430\u043c\u0438, \u0432 \u0442\u043e\u043c \u0432\u0438\u0434\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043e\u0431\u044a\u0435\u043a\u0442\u043d\u044b\u043c \u0433\u0440\u0430\u0444\u043e\u043c \u0432 \u043e\u0431\u044b\u0447\u043d\u043e\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u043d\u043e-\u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u043c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438.<\/p>\n<p>  <b>\u0417\u043d\u0430\u0435\u0442\u0435 \u043b\u0438 \u0412\u044b?<\/b>  <\/p>\n<blockquote><p>Core Data \u0431\u044b\u043b \u0432\u043d\u0435\u0434\u0440\u0451\u043d \u043b\u0438\u0448\u044c \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 Mac OS X 10.4 Tiger \u0438 iPhone SDK 3.0  <\/p><\/blockquote>\n<h5>\u0418\u0441\u0442\u043e\u0440\u0438\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 iOS<\/h5>\n<p>  \u041a\u0430\u043a \u0437\u0430 \u0432\u044b\u043f\u0443\u0449\u0435\u043d\u043d\u044b\u0435 Pixar \u043c\u0443\u043b\u044c\u0442\u0444\u0438\u043b\u044c\u043c\u044b \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u0438\u0442\u044c \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u044e NeXT, \u0442\u0430\u043a \u0438 \u0437\u0430 Core Data \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0441\u043a\u0430\u0437\u0430\u0442\u044c \u0435\u0439 \u0441\u043f\u0430\u0441\u0438\u0431\u043e. Core Data \u0440\u043e\u0434\u0438\u043b\u0430\u0441\u044c \u0438 \u044d\u0432\u043e\u043b\u044e\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043b\u0430 \u0438\u0437 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0438, \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u043e\u0439 Enterprise Objects Framework (EOF). <br \/>  \u0414\u0435\u0431\u044e\u0442 \u0444\u0440\u044d\u0439\u043c\u0432\u043e\u0440\u043a\u0430 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043d\u0430 2005 \u0433\u043e\u0434 \u0441 \u0437\u0430\u043f\u0443\u0441\u043a\u043e\u043c Mac OS X 10.4 (Tiger), \u0430 \u0432\u043e\u0442 \u0432 IPhone \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0438\u0448\u044c \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 \u0432\u0435\u0440\u0441\u0438\u0438 3.0.<br \/>  \u0414\u043e \u0442\u043e\u0433\u043e, \u043a\u0430\u043a Core Data \u043f\u0440\u0438\u0448\u043b\u0430 \u043d\u0430 IPhone, \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430\u043c \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u043b\u043e\u0441\u044c \u043d\u0435 \u0441\u043b\u0430\u0434\u043a\u043e \u0438 \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u043e\u0433\u043b\u0438 \u0431\u044b\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u044b \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b:<br \/>  1) \u0421\u043f\u0438\u0441\u043a\u0438 \u0441\u0432\u043e\u0439\u0441\u0442\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043b\u0438 \u043f\u0430\u0440\u044b \u043a\u043b\u044e\u0447-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0438\u0437 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445.<br \/>  2) \u0421\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0438\u0445 \u0432 \u0444\u0430\u0439\u043b\u0430\u0445 (\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0441\u044f \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b NSCoding)<br \/>  3) \u0420\u0435\u043b\u044f\u0446\u0438\u043e\u043d\u043d\u0430\u044f \u0431\u0430\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 SQLite<br \/>  4) \u0425\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u043e\u0431\u043b\u0430\u043a\u0435<\/p>\n<p>  \u042d\u0442\u0438 \u043c\u0435\u0442\u043e\u0434\u044b \u0432\u0441\u0451 \u0435\u0449\u0435 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u044e\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f, \u0445\u043e\u0442\u044f \u0438 \u043d\u0438 \u043e\u0434\u0438\u043d \u043c\u0435\u0442\u043e\u0434 \u0438\u0437 \u0447\u0435\u0442\u044b\u0440\u0451\u0445 \u043d\u0435 \u0441\u0440\u0430\u0432\u043d\u0438\u0442\u0441\u044f \u043f\u043e \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0443 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c Core Data. \u041d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u0440\u043e\u0436\u0434\u0435\u043d\u0438\u0435 \u0442\u0430\u043a\u0438\u0445 \u0444\u0440\u044d\u0439\u043c\u0432\u043e\u0440\u043a\u043e\u043c, \u043a\u0430\u043a FMDatabase \u0438 ActiveRecord, \u0434\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0441 \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043e \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u044f Core Data, \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u0441 \u0443\u0434\u043e\u0432\u043e\u043b\u044c\u0441\u0442\u0432\u0438\u0435\u043c \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0438\u043b\u0438\u0441\u044c \u043d\u0430 Core Data \u043f\u043e\u0441\u043b\u0435 \u0435\u0433\u043e \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u044f.<br \/>  \u0425\u043e\u0442\u044f \u043f\u043e\u0432\u0442\u043e\u0440\u044e\u0441\u044c, \u0447\u0442\u043e Core Data \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0435\u043a\u0430\u0440\u0441\u0442\u0432\u043e\u043c \u043e\u0442 \u0432\u0441\u0435\u0445 \u0431\u043e\u043b\u0435\u0437\u043d\u0435\u0439, \u0438\u043d\u043e\u0433\u0434\u0430 \u0432\u044b \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0431\u0443\u0434\u0435\u0442\u0435 \u043e\u0431\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u043a \u0440\u0435\u0448\u0435\u043d\u0438\u044f\u043c \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u043f\u0438\u0441\u043a\u0430 \u0441\u0432\u043e\u0439\u0441\u0442\u0432, \u043d\u043e \u0447\u0430\u0449\u0435 \u0432\u0441\u0435\u0433\u043e \u0432\u044b \u0431\u0443\u0434\u0435\u0442\u0435 \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u0441 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c\u044e \u0438 \u0436\u0435\u043b\u0430\u043d\u0438\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u0441\u0432\u043e\u0438\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u0445 \u0438\u043c\u0435\u043d\u043d\u043e Core Data, \u043a\u0430\u043a \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u0438\u043b\u0443\u0447\u0448\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0440\u0435\u0448\u0438\u0442\u044c \u0432\u0430\u0448\u0443 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443.<br \/>  \u0427\u0435\u043c \u0447\u0430\u0449\u0435 \u0438 \u0447\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u0432\u044b \u0431\u0443\u0434\u0435\u0442\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Core Data, \u0442\u0435\u043c \u0447\u0430\u0449\u0435 \u0443 \u0432\u0430\u0441 \u0431\u0443\u0434\u0435\u0442 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0442\u044c \u043d\u0435 \u0432\u043e\u043f\u0440\u043e\u0441 \u00ab\u0421\u0442\u043e\u0438\u0442 \u043b\u0438 \u043c\u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Core Data?\u00bb, \u0430 \u00ab\u0415\u0441\u0442\u044c \u043b\u0438 \u043f\u0440\u0438\u0447\u0438\u043d\u0430 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Core Data?\u00bb.<\/p>\n<h5>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0441 Core Data<\/h5>\n<p>  \u0412 \u044d\u0442\u043e\u0439 \u0441\u0435\u043a\u0446\u0438\u0438 \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u043d\u0430 Core Data \u0438\u0437 \u043e\u0434\u043d\u043e\u0433\u043e \u0438\u0437 \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432 XCode, \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0447\u0430\u0441\u0442\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0440\u0430\u0437\u0431\u0435\u0440\u0451\u043c. \u0412 \u043a\u043e\u043d\u0446\u0435 \u044d\u0442\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u0432\u044b \u043f\u043e\u0439\u043c\u0435\u0442\u0435, \u043a\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0443\u0435\u0442 \u0441 Core Data \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<h5>\u041f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432 Core Data<\/h5>\n<p>  \u041f\u0435\u0440\u0435\u0434 \u0442\u0435\u043c, \u043a\u0430\u043a \u043f\u043e\u0433\u0440\u0443\u0437\u0438\u0442\u044c\u0441\u044f \u0432 \u043a\u043e\u0434 \u0438 \u0440\u0430\u0437\u0431\u043e\u0440 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0438\u043c\u0435\u0442\u044c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430\u0445 Core Data. \u041d\u0430 \u0440\u0438\u0441\u0443\u043d\u043a\u0435 \u043d\u0438\u0436\u0435 \u043f\u0440\u043e\u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438.<br \/>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/3d0\/440\/5df\/3d04405dfc6716686a37fc5e88d14b3a.png\"\/><br \/>  \u041a\u0430\u043a \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c Core Data \u0432\u044b \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0441 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0445. \u0410\u0431\u0441\u0442\u0440\u0430\u0433\u0438\u0440\u0443\u0439\u0442\u0435\u0441\u044c \u043e\u0442 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430, \u043e\u0442 \u0442\u0438\u043f\u0430 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430, \u0434\u0443\u043c\u0430\u0439\u0442\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043e \u0434\u0430\u043d\u043d\u044b\u0445! \u041e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044c\u044e \u0442\u0430\u043a\u043e\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0431\u0435\u0437\u0431\u043e\u043b\u0435\u0437\u043d\u0435\u043d\u043d\u043e \u0441\u043c\u0435\u043d\u0438\u0442\u044c \u0442\u0438\u043f \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430 (\u0431\u044b\u043b XML \u0444\u0430\u0439\u043b, \u0430 \u0441\u0442\u0430\u043b SQLite) \u043d\u0435 \u043c\u0435\u043d\u044f\u044f \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043a\u043e\u043b-\u0432\u0430 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0433\u043e \u0432\u0430\u043c\u0438 \u043a\u043e\u0434\u0430.<br \/>  \u041e\u0431\u044a\u0435\u043a\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u043f\u043e\u0434 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u0444\u0440\u044d\u0439\u043c\u0432\u043e\u0440\u043a\u0430 (Core Data) \u0434\u043e\u043b\u0436\u043d\u044b \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u044b\/\u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u043a\u043b\u0430\u0441\u0441\u0430 NSManagedObject.<br \/>  \u0422\u0430\u043a \u0436\u0435, \u043a\u0430\u043a \u0438 \u043b\u044e\u0434\u044f\u043c, \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c \u043d\u0443\u0436\u043d\u0430 \u0441\u0440\u0435\u0434\u0430 \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043e\u043d\u0438 \u043c\u043e\u0433\u0443\u0442 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c, \u0442\u0430\u043a\u0430\u044f \u0441\u0440\u0435\u0434\u0430 \u0435\u0441\u0442\u044c \u0438, \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043e\u043d\u0430 managed object context (\u0441\u0440\u0435\u0434\u0430 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432) \u0438\u043b\u0438 \u043f\u0440\u043e\u0441\u0442\u043e context. \u0421\u0440\u0435\u0434\u0430, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043e\u0431\u044a\u0435\u043a\u0442, \u0441\u043b\u0435\u0434\u0438\u0442\u044c \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0437\u0430 \u0442\u0435\u043c, \u0432 \u043a\u0430\u043a\u043e\u043c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0438 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043e\u0431\u044a\u0435\u043a\u0442 \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0432\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442\u0435, \u043d\u043e \u0438 \u0437\u0430 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f\u043c\u0438 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 (\u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b \u043e\u0442 \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0438 \u043e\u0442 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0437\u0430\u0432\u0438\u0441\u0438\u043c \u043e\u043d \u0441\u0430\u043c).<br \/>  \u042d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043a\u043b\u0430\u0441\u0441\u0430 NSManagedObjectContext \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0442\u0443 \u0441\u0430\u043c\u0443\u044e \u0441\u0440\u0435\u0434\u0443 \u0434\u043b\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432, \u043e\u0431\u044a\u0435\u043a\u0442 \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u0432 \u0432\u0430\u0448\u0435\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u0432\u0441\u0435\u0433\u0434\u0430. \u041e\u0431\u044b\u0447\u043d\u043e \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043a\u043b\u0430\u0441\u0441\u0430 NSManagedObjectContext \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e\u043c \u0434\u0435\u043b\u0435\u0433\u0430\u0442\u0430 \u0432\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u0411\u0435\u0437 \u0441\u0440\u0435\u0434\u044b, \u0431\u0435\u0437 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430 \u043a\u043b\u0430\u0441\u0441\u0430 NSManagedObjectContext \u0432\u0430\u043c \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435 \u0443\u0434\u0430\u0441\u0442\u0441\u044f \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 Core Data.<\/p>\n<h5>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043d\u043e\u0432\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430<\/h5>\n<p>  \u0417\u0430\u043f\u0443\u0441\u0442\u0438\u043c XCode \u0438 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043d\u043e\u0432\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442 \u0438\u0437 \u0448\u0430\u0431\u043b\u043e\u043d\u0430 Master-Detail Application:<br \/>  <img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/b73\/118\/4a6\/b731184a6ca115e10c54d534e330dc24.png\" alt=\"image\"\/><\/p>\n<p>  \u0417\u0430\u043f\u043e\u043b\u043d\u0438\u043c \u043f\u043e\u043b\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<br \/>  <img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/dbd\/8e8\/528\/dbd8e8528d8e4bf5df7632d2e676a4ff.png\" alt=\"image\"\/><\/p>\n<p>  \u0418 \u043f\u043e\u0441\u043b\u0435 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0443\u0432\u0438\u0434\u0438\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a\u0443\u044e \u043a\u0430\u0440\u0442\u0438\u043d\u0443:<br \/>  <img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/84f\/6f9\/e21\/84f6f9e21474a79f5ac26a26674124ff.png\" alt=\"image\"\/><\/p>\n<h5>\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043d\u0430\u0448 \u043f\u0440\u043e\u0435\u043a\u0442<\/h5>\n<p>  \u041f\u0435\u0440\u0435\u0434 \u0442\u0435\u043c \u043a\u0430\u043a \u043d\u0430\u0447\u0430\u0442\u044c \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u043e\u0434 \u043a\u0430\u043f\u043e\u0442\u043e\u043c \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u0438 \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c\u0441\u044f, \u0447\u0442\u043e \u0432\u043e\u043e\u0431\u0449\u0435 \u0434\u0435\u043b\u0430\u0435\u0442 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435. <br \/>  \u0416\u043c\u0451\u043c \u043d\u0430 \u043a\u043d\u043e\u043f\u043a\u0443 \u00abRun\u00bb \u0438 \u043f\u0435\u0440\u0435\u0434 \u043d\u0430\u043c\u0438 \u043f\u043e\u044f\u0432\u0438\u0442\u0441\u044f \u0432\u043e\u0442 \u0442\u0430\u043a\u043e\u0435:<br \/>  <img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/0e6\/852\/fe1\/0e6852fe1f396c4dac0c6da9db946c9b.png\" alt=\"image\"\/><\/p>\n<p>  \u041d\u0430\u0436\u043c\u0435\u043c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437 \u043d\u0430 \u043a\u043d\u043e\u043f\u043a\u0443 \u0441 &quot;+&quot; \u0438 \u0432 \u0441\u043f\u0438\u0441\u043a\u0435 \u043f\u043e\u044f\u0432\u0438\u0442\u0441\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0441\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0435\u043c.<br \/>  <img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/f02\/36c\/e50\/f0236ce50796dab251dd2c5157398e8b.png\" alt=\"image\"\/><\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u043c (\u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c) \u0440\u0430\u0431\u043e\u0442\u0443 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0438, \u0435\u0441\u043b\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u043e \u0431\u044b Core Data \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445, \u0442\u043e \u043f\u0440\u0438 \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u043c \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u043c\u044b \u0443\u0432\u0438\u0434\u0435\u043b\u0438 \u0431\u044b \u043f\u0443\u0441\u0442\u043e\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u0441\u043d\u043e\u0432\u0430, \u043e\u0434\u043d\u0430\u043a\u043e \u043f\u043e\u0441\u043b\u0435 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043c\u044b \u0432\u0438\u0434\u0438\u043c \u0432\u0441\u0451 \u0442\u0443 \u0436\u0435 \u043a\u0430\u0440\u0442\u0438\u043d\u0443:<br \/>  <img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/e19\/5fe\/8b0\/e195fe8b0a6f08dde9f8743ff294fc51.png\" alt=\"image\"\/><\/p>\n<h5>\u0420\u0430\u0437\u0431\u0438\u0440\u0430\u0435\u043c \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f<\/h5>\n<p>  \u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u0430. \u0412 \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u043c\u043e\u0434\u0435\u043b\u044c \u0434\u0430\u043d\u043d\u044b\u0445, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c \u0445\u0440\u0430\u043d\u0438\u043c\u0443\u044e \u0432 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 (\u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435); \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0431\u043b\u0435\u0433\u0447\u0430\u0435\u0442 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043c\u0435\u0436\u0434\u0443 \u044d\u043a\u0440\u0430\u043d\u043e\u043c (\u0442\u0430\u0431\u043b\u0438\u0446\u0435\u0439) \u0438 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0445; \u0434\u0435\u043b\u0435\u0433\u0430\u0442 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435.<br \/>  \u041d\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0438 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u043e\u043c \u043d\u0438\u0436\u0435 \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u044b \u043a\u043b\u0430\u0441\u0441\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u0438 \u043a\u0430\u043a \u043e\u043d\u0438 \u0441\u043e\u043e\u0442\u043d\u043e\u0441\u044f\u0442\u0441\u044f \u0434\u0440\u0443\u0433 \u0441 \u0434\u0440\u0443\u0433\u043e\u043c:<br \/>  <img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/c49\/d4b\/899\/c49d4b899a50d22aa8279a8056cbc18d.png\" alt=\"image\"\/><\/p>\n<p>  \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u043a\u043b\u0430\u0441\u0441 MasterViewController \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0441\u0441\u044b\u043b\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043a\u043b\u0430\u0441\u0441\u0430 NSManagedObjectContext \u0434\u043b\u044f \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441 Core Data. \u041f\u0440\u043e\u0439\u0434\u044f\u0441\u044c \u043f\u043e \u043a\u043e\u0434\u0443 \u043c\u043e\u0436\u043d\u043e \u0443\u0432\u0438\u0434\u0435\u0442\u044c, \u0447\u0442\u043e MasterViewController \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 managed object context \u0438\u0437 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0434\u0435\u043b\u0435\u0433\u0430\u0442\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. <\/p>\n<pre><code class=\"objectivec\">- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];    if(self){       self.title = NSLocalizedString(@&quot;Master&quot;, @&quot;Master&quot;);       id delegate = [[UIApplication sharedApplication] delegate];       self.managedObjectContext = [delegate managedObjectContext];    }        return self; } <\/code><\/pre>\n<p>  BasicApplication.xcdatamodel \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e \u0432 \u0444\u0430\u0439\u043b\u043e\u0432\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u0435, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0445. \u041c\u043e\u0434\u0435\u043b\u044c \u0434\u0430\u043d\u043d\u044b\u0445 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0441\u043d\u043e\u0432\u043e\u0439 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0435\u0433\u043e Core Data. <br \/>  \u041c\u043e\u0434\u0435\u043b\u044c \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u043b\u0438\u0448\u044c \u043e\u0434\u043d\u0443 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c \u2014 Event. \u0421\u0443\u0449\u043d\u043e\u0441\u0442\u044c Event \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043b\u0438\u0448\u044c \u043e\u0434\u043d\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e (\u043f\u043e\u043b\u0435, \u0430\u0442\u0440\u0438\u0431\u0443\u0442) \u2014 timeStamp \u0442\u0438\u043f\u0430 Date.<br \/>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/a85\/5b2\/149\/a855b21498a3abe1213f1a88cd98ad81.png\"\/><\/p>\n<p>  \u0421\u0443\u0449\u043d\u043e\u0441\u0442\u044c Event \u0442\u0438\u043f\u0430 NSManagedObject, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u043c \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439 \u043d\u0430\u0445\u043e\u0434\u044f\u0449\u0438\u043c\u0441\u044f \u043f\u043e\u0434 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c Core Data. \u0412\u043e \u0432\u0442\u043e\u0440\u043e\u0439 \u0433\u043b\u0430\u0432\u0435 \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0442\u0438\u043f NSManagedObject \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e.<\/p>\n<h5>\u0418\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u0435\/\u0432\u044b\u0431\u043e\u0440\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445<\/h5>\n<p>  \u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043a\u043b\u0430\u0441\u0441\u043e\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u0441 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u0435\u0442, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f MasterViewController. \u0412 \u0435\u0433\u043e \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u0447\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u044b \u0434\u0432\u0430 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u043e\u0431\u0440\u0430\u0442\u0438\u043c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435:  <\/p>\n<pre><code class=\"objectivec\">@property (nonatomic, strong) NSFetchedResultsController *fetchedResultsController; @property (nonatomic, strong) NSManagedObjectContext *managedObjectContext; <\/code><\/pre>\n<p>  NSFetchedResultsController \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440, \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c\u044b\u0439 \u0444\u0440\u044d\u0439\u043c\u0432\u043e\u0440\u043a\u043e\u043c Core Data \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430\u043c\u0438 \u043a \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0443.<br \/>  NSManagedObjectContext \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e\u0439 \u043d\u0430\u043c \u0443\u0436\u0435 \u0441\u0440\u0435\u0434\u043e\u0439 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0442\u0438\u043f\u0430 NSManagedObject.<\/p>\n<p>  \u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043a\u043b\u0430\u0441\u0441\u0430 MasterViewController, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0432 \u0444\u0430\u0439\u043b\u0435 MasterViewController.m, \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u043a\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043c\u043e\u0436\u043d\u043e \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0441 Core Data \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0438 \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445. \u0412 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u043b\u0430\u0441\u0441\u0430 MasterVIewController \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u044f\u0432\u043d\u044b\u0439 \u0433\u0435\u0442\u0442\u0435\u0440 fetchedResultsController, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442 \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0443 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043d\u0430 \u0432\u044b\u0431\u043e\u0440\u043a\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430.<\/p>\n<p>  \u041f\u0435\u0440\u0432\u044b\u043c \u0448\u0430\u0433\u043e\u043c \u043a \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u0435\u043d\u0438\u044e \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043d\u0430 \u0432\u044b\u0431\u043e\u0440\u043a\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u0430:  <\/p>\n<pre><code class=\"objectivec\">NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init]; NSEntityDescription *entity = [NSEntityDescription entityForName:@&quot;Event&quot; inManagedObjectContext:self.managedObjectContext]; [fetchRequest setEntity:entity]; <\/code><\/pre>\n<p>  \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043e\u0442\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 NSSortDescriptor. NSSortDescriptor \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u043f\u043e\u043b\u0435 \u0434\u043b\u044f \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438 \u0438 \u0442\u0438\u043f \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438 (\u043f\u043e \u0432\u043e\u0437\u0440\u0430\u0441\u0442\u0430\u043d\u0438\u044e \u0438\u043b\u0438 \u0443\u0431\u044b\u0432\u0430\u043d\u0438\u044e).<br \/>  \u0412 \u043d\u0430\u0448\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0441\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u043f\u043e \u0443\u0431\u044b\u0432\u0430\u043d\u0438\u044e \u0432\u0440\u0435\u043c\u0435\u043d\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0437\u0430\u043f\u0438\u0441\u0435\u0439:  <\/p>\n<pre><code class=\"objectivec\">NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@&quot;timeStamp&quot; ascending:NO]; NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:sortDescriptor, nil]; [fetchRequest setSortDescriptors:sortDescriptors]; <\/code><\/pre>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0437\u0430\u043f\u0440\u043e\u0441 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u0442\u044c \u043a \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e NSFetchedResultsController.<br \/>  \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0434\u0435\u043b\u0435\u0433\u0430\u0442\u0430 NSFetchedResultsController MasterVIewController \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u043b\u0435\u0434\u0438\u0442\u044c \u0437\u0430 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0445 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430 (\u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435, \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435, \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u0438 \u0442\u0434) \u0438 \u0431\u0435\u0437\u0431\u043e\u043b\u0435\u0437\u043d\u0435\u043d\u043d\u043e \u0438\u043d\u0442\u0435\u0433\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0441 UITableView. \u041c\u044b \u043c\u043e\u0436\u0435\u043c \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0436\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0442\u0435 \u0436\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0432\u044b\u0437\u044b\u0432\u0430\u044f \u043c\u0435\u0442\u043e\u0434 executeFetchRequest \u0432 managed object context, \u043d\u043e \u0432 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u044b \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0438 \u043d\u0435 \u0441\u043c\u043e\u0436\u0435\u043c \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0432\u0441\u0435\u043c\u0438 \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430\u043c\u0438 NSFetchedResultsController.<br \/>  \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430 \u043a\u043b\u0430\u0441\u0441\u0430 NSFetchedResultsController:  <\/p>\n<pre><code class=\"objectivec\">NSFetchedResultsController *aFetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext:self.managedObjectContext sectionNameKeyPath:nil cacheName:@&quot;Master&quot;]; aFetchedResultsController.delegate = self; self.fetchedResultsController = aFetchedResultsController; <\/code><\/pre>\n<p>  <b>\u0417\u043d\u0430\u0435\u0442\u0435 \u043b\u0438 \u0412\u044b?<\/b>  <\/p>\n<blockquote><p>\u0412\u044b \u043d\u0430\u0432\u0435\u0440\u043d\u043e \u0437\u0430\u043c\u0435\u0442\u0438\u043b\u0438, \u0447\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0439 \u0440\u0430\u043d\u0435\u0435 \u043c\u0435\u0442\u043e\u0434 initWithFetchRequest \u0438\u043c\u0435\u0435\u0442 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 cacheName. \u041f\u0440\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0435 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430 nil \u0412\u044b \u0438\u0441\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043a\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u0430, \u043d\u043e \u043f\u0440\u0438 \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u0438 \u043d\u0430\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u044d\u0448\u0430, \u0432\u044b \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442\u0435 Core Data \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u0442\u0430\u043a\u043e\u0433\u043e \u0436\u0435 \u0440\u0430\u043d\u0435\u0435 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0438 \u0432\u0435\u0440\u043d\u0443\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0438\u0437 \u043a\u044d\u0448\u0430. \u0412 \u043f\u0440\u043e\u0442\u0438\u0432\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0441\u043b\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0441 \u0442\u0430\u043a\u0438\u043c \u0438\u043c\u0435\u043d\u0435\u043c \u043a\u044d\u0448\u0430 \u043d\u0435\u0442, \u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u0435\u043d \u0437\u0430\u043f\u0440\u043e\u0441 \u043a \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0443 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0435\u043d\u044b \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043a\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u0432\u043f\u043e\u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0438.  <\/p><\/blockquote>\n<p>  \u0412 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u0435 \u043d\u0430\u043c \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441 \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445:  <\/p>\n<pre><code class=\"objectivec\">NSError *error = nil; if(![self.fetchedResultsController performFetch:&error]){    NSLog(@&quot;Unresolved error %@, %@&quot;, error, [error userInfo]);    abort(); } <\/code><\/pre>\n<p>  \u041d\u0438\u0436\u0435 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u0441 \u043f\u043e\u043b\u043d\u044b\u043c \u0433\u0435\u0442\u0442\u0435\u0440\u043e\u043c fetchedResultsController:  <\/p>\n<pre><code class=\"objectivec\">- (NSFetchedResultsController *)fetchedResultsController {     if (_fetchedResultsController != nil)         return _fetchedResultsController;     NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];    NSEntityDescription *entity = [NSEntityDescription entityForName:@&quot;Event&quot; inManagedObjectContext:self.managedObjectContext];    [fetchRequest setEntity:entity];      [fetchRequest setFetchBatchSize:20];      NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@&quot;timeStamp&quot; ascending:NO];    NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:sortDescriptor, nil];    [fetchRequest setSortDescriptors:sortDescriptors];      NSFetchedResultsController *aFetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext:self.managedObjectContext sectionNameKeyPath:nil cacheName:@&quot;Master&quot;];    aFetchedResultsController.delegate = self;    self.fetchedResultsController = aFetchedResultsController;      NSError *error = nil;    if(![self.fetchedResultsController performFetch:&error]){       NSLog(@&quot;Unresolved error %@, %@&quot;, error, [error userInfo]);       abort();    }      return __fetchedResultsController; } <\/code><\/pre>\n<p>  NSFetchedResultsController \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u043d\u0435\u0447\u0442\u043e \u0432\u0440\u043e\u0434\u0435 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0442\u0438\u043f\u0430 NSManagedObject, \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0443 \u043d\u0435\u0433\u043e \u0434\u0430\u0436\u0435 \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 fetchedObjects \u0442\u0438\u043f\u0430 NSArray \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u0430.<br \/>  \u041a\u043b\u0430\u0441\u0441 MasterVIewController, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0442\u0430\u043a \u0436\u0435 \u0440\u0430\u0441\u0448\u0438\u0440\u044f\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 UITableViewController, \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442 \u043d\u0430\u043c \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0443\u0434\u043e\u0431\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c NSFetchedResultsController \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u044b\u043c \u0442\u0430\u0431\u043b\u0438\u0446.<\/p>\n<h5>\u0412\u0441\u0442\u0430\u0432\u043a\u0430 \u043d\u043e\u0432\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430<\/h5>\n<p>  \u0411\u044b\u0441\u0442\u0440\u043e \u043e\u043a\u0438\u043d\u0443\u0432 \u0432\u0437\u0433\u043b\u044f\u0434\u043e\u043c \u043c\u0435\u0442\u043e\u0434 insertNewObject: \u0441\u0442\u0430\u043d\u0435\u0442 \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u043a\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0441\u043e\u0437\u0434\u0430\u044e\u0442\u0441\u044f \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043d\u043e\u0432\u044b\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u0432 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435. NSManagedObject \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0442\u0441\u044f \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435\u043c \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u0438\u0437 \u043c\u043e\u0434\u0435\u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u043c\u043e\u0433\u0443\u0442 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u043c \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 (\u0441\u0440\u0435\u0434\u0435). \u041f\u0435\u0440\u0432\u044b\u043c \u0448\u0430\u0433\u043e\u043c \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043d\u043e\u0432\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430 \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u044d\u0442\u043e\u0442 \u043e\u0431\u044a\u0435\u043a\u0442 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u043d:  <\/p>\n<pre><code class=\"objectivec\">NSManagedObjectContext *managedObjectContext = [self.fetchedResultsController managedObjectContext]; NSEntityDescription *entity = [[self.fetchedResultsController fetchRequest] entity]; <\/code><\/pre>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0451\u043c NSManagedObject:  <\/p>\n<pre><code class=\"objectivec\">NSManagedObject *newManagedObject = [NSEntityDescription insertNewObjectForEntity:[entity name] inManagedObjectContext:context]; [newManagedObject setValue:[NSDate date] forKey:@&quot;timeStamp&quot;]; <\/code><\/pre>\n<p>  \u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u043c \u0448\u0430\u0433\u043e\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0438\u0442\u044c, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430 \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0431\u044b\u043b \u0441\u043e\u0437\u0434\u0430\u043d \u043d\u043e\u0432\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442. \u0423\u0447\u0442\u0438\u0442\u0435, \u0447\u0442\u043e \u043f\u0440\u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0438 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430 \u0432\u0441\u0435 \u043d\u0435\u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u043d\u044b\u0435 \u0440\u0430\u043d\u0435\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0431\u0443\u0434\u0443\u0442 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u044b.  <\/p>\n<pre><code class=\"objectivec\">NSError *error = nil; if(![context save:&error]){    NSLog(@&quot;Unresolved error: %@, %@&quot;, error, [error userInfo]);    abort(); } <\/code><\/pre>\n<p>  \u041f\u043e\u043b\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043d\u043e\u0432\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u043d\u0438\u0436\u0435:  <\/p>\n<pre><code class=\"objectivec\">- (void)insertNewObject {    NSManagedObjectContext *managedObjectContext = [self.fetchedResultsController managedObjectContext];    NSEntityDescription *entity = [[self.fetchedResultsController fetchRequest] entity];    NSManagedObject *newManagedObject = [NSEntityDescription insertNewObjectForEntityForName:[entity name] inManagedObjectContext:context];     [newManagedObject setValue:[NSDate date] forKey:@&quot;timeStamp&quot;];     NSError *error = nil;    if(![context save:&error]){       NSLog(@&quot;Unresolved error: %@, %@&quot;, error, [error userInfo]);       abort();    } } <\/code><\/pre>\n<h5>\u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430 (\u0441\u0440\u0435\u0434\u044b)<\/h5>\n<p>  \u041e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u0432\u0441\u0451, \u0447\u0442\u043e \u043c\u044b \u0440\u0430\u043d\u044c\u0448\u0435 \u0434\u0435\u043b\u0430\u043b\u0438 \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0434\u043e\u0441\u0442\u0438\u0433\u043d\u0443\u0442\u043e \u0431\u0435\u0437 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430, \u0431\u0435\u0437 \u0442\u043e\u0439 \u0441\u0430\u043c\u043e\u0439 \u0441\u0440\u0435\u0434\u044b \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0438 \u0436\u0438\u0432\u0435\u0442 \u043e\u0431\u044a\u0435\u043a\u0442. \u041a\u0430\u043a \u0440\u0430\u0437 \u0437\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u044d\u0442\u043e\u0439 \u0441\u0430\u043c\u043e\u0439 \u0441\u0440\u0435\u0434\u044b \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0434\u0435\u043b\u0435\u0433\u0430\u0442 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u0422\u0440\u0438 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0432 \u043b\u044e\u0431\u043e\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0435\u043c Core Data \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438:  <\/p>\n<pre><code class=\"objectivec\">@property (readonly, strong, nonatomic) NSManagedObjectContext *managedObjectContext; @property (readonly, strong, nonatomic) NSManagedObjectModel *managedObjectModel; @property (readonly, strong, nonatomic) NSPersistentStoreCoordinator *persistentStoreCoordinator; <\/code><\/pre>\n<p>  \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u0432\u0441\u0435 \u0442\u0440\u0438 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 readonly, \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u044d\u0442\u043e \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0438\u0437\u0432\u043d\u0435 \u0438\u0445 \u043d\u0435\u043b\u044c\u0437\u044f \u0431\u044b\u043b\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c. \u0418\u0437\u0443\u0447\u0430\u044f BasicApplicationAppDelegate.m \u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u0432\u0441\u0435 \u0442\u0440\u0438 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0438\u043c\u0435\u044e\u0442 \u044f\u0432\u043d\u044b\u0435 \u0433\u0435\u0442\u0442\u0435\u0440\u044b.<\/p>\n<p>  Managed Object Model:  <\/p>\n<pre><code class=\"objectivec\">- (NSManagedObjectModel *)managedObjectModel {    if(_managedObjectModel != nil){       return _managedObjectModel;    }     NSURL *modelURL = [[NSBundle mainBundle] URLForResource:@&quot;BasicApplication&quot; withExtension:@&quot;momd&quot;];    _managedObjectModel = [[NSManagedObjectModel alloc] initWithContentsOfURL:modeURL];     return _managedObjectModel; } <\/code><\/pre>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0449\u0435\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0445. \u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u043a\u0430\u043a \u0438 \u0432 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0435 \u0434\u0440\u0443\u0433\u0438\u0445 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c Core Data, \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u043e\u0441\u043d\u043e\u0432\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 SQLite.   <\/p>\n<pre><code class=\"objectivec\">- (NSPersistentStoreCoordinator *)persistentStoreCoordinator {    if(_persistentStoreCoordinator != nil){       return _persistentStoreCoordinator;    }     NSURL *storeURL = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:@&quot;BasicApplication.sqlite&quot;];     NSError* error = nil;    _persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:[self managedObjectModel]];    if(![_persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL options:nil error:&error]){       NSLog(@&quot;Unresolved error %@, %@&quot;, error, [error userInfo]);       abort();    }     return _persistentStoreCoordinator; } <\/code><\/pre>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0451\u043c \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 (\u0441\u0440\u0435\u0434\u0443):  <\/p>\n<pre><code class=\"objectivec\">- (NSManagedObjectContext *)managedObjectContext {    if(_managedObjectContext != nil){       return _managedObjectContext;    }     NSPersistentStoreCoordinator *coordinator = [self persistentStoreCoordinator];    if(coordinator != nil){       _managedObjectContext = [[NSManagedObjectContext alloc] init];       [_managedObjectContext setPersistentStoreCoordinator:coordinator];    }     return _managedObjectContext; } <\/code><\/pre>\n<p>  \u041a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432\u043e \u0432\u0441\u0451\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 \u0434\u043b\u044f \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441 Core Data \u0438 \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u044b\u043c \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435\u043c.<br \/>  \u041f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 Core Data:<br \/>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/dea\/351\/844\/dea3518443d04e9c16eaed969549ed3c.png\"\/><\/p>\n<p>  \u041c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u0432\u044b\u0437\u043e\u0432\u0435 \u043c\u0435\u0442\u043e\u0434\u0430 application:didFinishLaunchingWithOptions:  <\/p>\n<pre><code class=\"objectivec\">- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];     MasterViewController *controller = [[MasterViewController alloc] initWithNibName:@&quot;MasterViewController&quot; bundle:nil];    self.navigationController = [[UINavigationController alloc] initWithRootViewController:controller];    self.window.rootViewController = self.navigationController;     [self.window makeKeyAndVisible];    return YES; } <\/code><\/pre>\n<p>  \u00a0\u0412\u044b\u0437\u044b\u0432\u0430\u044f \u0433\u0435\u0442\u0442\u0435\u0440 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 managedObjectContext \u0434\u0435\u043b\u0435\u0433\u0430\u0442\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043d\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u0446\u0435\u043f\u043e\u0447\u043a\u0430 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439:<br \/>   \u2014 (NSManagedObjectContext *)managedObjectContext \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442<br \/>   \u2014 (NSPersistentStoreCoordinator *)persistentStoreCoordinator, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442 \u0432\u044b\u0437\u043e\u0432<br \/>   \u2014 (NSManagedObjectModel *)managedObjectModel. <br \/>  \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0432\u044b\u0437\u043e\u0432 \u0433\u0435\u0442\u0442\u0435\u0440-\u043c\u0435\u0442\u043e\u0434\u0430 managedObjectContext \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u0442 \u0432\u0435\u0441\u044c \u0441\u0442\u044d\u043a \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 Core Data \u0438 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 Core Data \u0432 \u0433\u043e\u0442\u043e\u0432\u043d\u043e\u0441\u0442\u044c.<\/p>\n<h5>\u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 Core Data \u0432 \u0443\u0436\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u043f\u0440\u043e\u0435\u043a\u0442<\/h5>\n<p>  \u041e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432 \u0442\u0440\u0438 \u0448\u0430\u0433\u0430:  <\/p>\n<ol>\n<li> \u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0444\u0440\u044d\u0439\u043c\u0432\u043e\u0440\u043a\u0430 Core Data<\/li>\n<li> \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0445<\/li>\n<li> \u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430 (\u0441\u0440\u0435\u0434\u044b)<\/li>\n<\/ol>\n<h5>\u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0444\u0440\u044d\u0439\u043c\u0432\u043e\u0440\u043a\u0430 Core Data<\/h5>\n<p>  \u0412 \u043c\u0438\u0440\u0435 Objective-C \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u043d\u0430\u0437\u044b\u0432\u0430\u044e\u0442 \u0444\u0440\u044d\u0439\u043c\u0432\u043e\u0440\u043a\u0430\u043c\u0438.<br \/>  \u0421\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0435 \u0444\u0440\u044d\u0439\u043c\u0432\u043e\u0440\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0443\u0436\u0435 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u044b \u0432 \u00ab\u0447\u0438\u0441\u0442\u044b\u0445\u00bb \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445 \u0438 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u044b \u0447\u0430\u0449\u0435 \u0432\u0441\u0435\u0433\u043e \u0443\u0432\u0438\u0434\u0438\u0442\u0435:  <\/p>\n<ul>\n<li> UIKit<\/li>\n<li> Foundation<\/li>\n<li> Core Graphics<\/li>\n<\/ul>\n<p>  \u0413\u0434\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043d\u043e\u0432\u044b\u0445 \u0444\u0440\u044d\u0439\u043c\u0432\u043e\u0440\u043a\u043e\u0432:<br \/>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/422\/042\/0e9\/4220420e9e6cc1b49fe03c73d141a92a.png\"\/><\/p>\n<p>  \u0412\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u0444\u0440\u044d\u0439\u043c\u0432\u043e\u0440\u043a \u0434\u043b\u044f \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f:<br \/>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/d4c\/7f4\/e86\/d4c7f4e8675e37c3ebfdbda2d8409009.png\"\/><\/p>\n<h5>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0445<\/h5>\n<p>  \u041d\u0438 \u043e\u0434\u043d\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 Core Data \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0441\u0447\u0438\u0442\u0430\u0442\u044c\u0441\u044f \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u044b\u043c \u0431\u0435\u0437 \u043c\u043e\u0434\u0435\u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0445. \u041c\u043e\u0434\u0435\u043b\u044c \u0434\u0430\u043d\u043d\u044b\u0445 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u0432\u0441\u0435 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0432 \u0432\u0435\u0434\u0435\u043d\u0438\u0438 Core Data. <br \/>  \u0414\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043d\u043e\u0432\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0445: File -&gt; New -&gt; New File<br \/>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/2d2\/b54\/868\/2d2b54868cad938ac6b4978d04cc61b2.png\"\/><\/p>\n<p>  \u041d\u0430\u0437\u043e\u0432\u0435\u043c \u043d\u0430\u0448\u0443 \u043c\u043e\u0434\u0435\u043b\u044c <b>MyModel.xcdatamodeld<\/b>:<br \/>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/fd0\/9e5\/509\/fd09e5509c9735d537d4f8a0cec985b7.png\"\/><\/p>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0438 \u043f\u0435\u0440\u0435\u0434 \u0432\u0430\u043c\u0438 \u043e\u0442\u043a\u0440\u043e\u0435\u0442\u0441\u044f \u043e\u043a\u043d\u043e \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f (\u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f) \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439. <br \/>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/456\/e88\/758\/456e887586fbd008fa672d6b8ece06fc.png\"\/><\/p>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0442\u044c \u043d\u043e\u0432\u0443\u044e \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c \u043c\u043e\u0436\u043d\u043e \u043a\u043b\u0438\u043a\u043d\u0443\u0432 \u043d\u0430 \u043a\u043d\u043e\u043f\u043a\u0443 &quot;+&quot; \u0432 \u043b\u0435\u0432\u043e\u0439 \u043d\u0438\u0436\u043d\u0435\u0439 \u0447\u0430\u0441\u0442\u0438 XCode, \u0430 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043d\u043e\u0432\u044b\u0439 \u0430\u0442\u0440\u0438\u0431\u0443\u0442 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0436\u0430\u0432 \u043d\u0430 \u043a\u043d\u043e\u043f\u043a\u0443 &quot;+&quot; \u0443\u0436\u0435 \u0432 \u0440\u0430\u0437\u0434\u0435\u043b\u0435 \u00abAttributes\u00bb \u0438 \u0437\u0430\u0442\u0435\u043c \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0435\u0433\u043e \u0442\u0438\u043f.<br \/>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/b79\/cda\/4be\/b79cda4be75982ade7806c7c59f88bf8.png\"\/><\/p>\n<h5>\u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430 (\u0441\u0440\u0435\u0434\u044b)<\/h5>\n<p>  \u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0448\u0430\u0433 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0432 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430, \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430 \u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438. \u0427\u0430\u0449\u0435 \u0432\u0441\u0435\u0433\u043e \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043a\u043e\u0434\u043e\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f XCode \u0432 \u00ab\u043f\u0443\u0441\u0442\u044b\u0445\u00bb \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0438\u0445 Core Data.<\/p>\n<p>  <b>DemoAppAppDelegate.h<\/b>  <\/p>\n<pre><code class=\"objectivec\">#import &lt;UIKit\/UIKit.h&gt; #import &lt;CoreData\/CoreData.h&gt;  @interface DemoAppDelegate : UIResponder &lt;UIApplicationDelegate&gt; { }  @property (strong, nonatomic) UIWindow *window; @property (strong, nonatomic) UINavigationController *navigationController;  @property (readonly, strong, nonatomic) NSManagedObjectModel *managedObjectModel; @property (readonly, strong, nonatomic) NSManagedObjectContext *managedObjectContext; @property (readonly, strong, nonatomic) NSPersistentStoreCoordinator *persistentStoreCoordinator;  - (void)saveContext; - (NSURL *)applicationsDocumentsDirectory;  @end <\/code><\/pre>\n<p>  \u041f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0438\u043c\u0441\u044f \u0432 *.m \u0444\u0430\u0439\u043b DemoAppAppDelegate \u0438 \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0441\u0442\u0440\u043e\u043a\u0438:  <\/p>\n<pre><code class=\"objectivec\">@synthesize managedObjectContext = _managedObjectContext; @synthesize managedObjectModel = _managedObjectModel; @synthesize persistentStoreCoordinator = _persistentStoreCoordinator; <\/code><\/pre>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043a\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043c\u043e\u0434\u0435\u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0445, \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430 \u0438 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430.  <\/p>\n<pre><code class=\"objectivec\">- (NSManagedObjectModel *)managedObjectModel {    if (_managedObjectModel != nil){       return _managedObjectModel;    }     NSURL *modelURL = [[NSBundle mainBundle] URLForResource:@&quot;MyModel&quot; withExtension:@&quot;momd&quot;];    _managedObjectModel = [[NSManagedObjectModel alloc] initWithContentsOfURL:modeURL];     return _managedObjectModel; } <\/code><\/pre>\n<pre><code class=\"objectivec\">- (NSPersistentStoreCoordinator *)persistentStoreCoordinator {    if(_persistentStoreCoordinator != nil){       return _persistentStoreCoordinator;    }     NSURL *storeURL = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:@&quot;DemoApp.sqlite&quot;];        NSError *error = nil;    _persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel: [self managedObjectModel]];    if(![_persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL options:nil error&error]){       NSLog(@&quot;Unresolved error %@, %@&quot;, error, [error userInfo]);       abort();    }     return _persistentStoreCoordinator; } <\/code><\/pre>\n<pre><code class=\"objectivec\">- (NSManagedObjectContext *)managedObjectContext {    if(_managedObjectContext != nil){       return _managedObjectContext;    }     NSPersistentStoreCoordinator *coordinator = [self persistentStoreCoordinator];    if(coordinator != nil){       _managedObjectContext = [[NSManagedObjectContext alloc] init];       [_managedObjectContext setPersistentStoreCoordinator:coordinator];    }     return _managedObjectContext; } <\/code><\/pre>\n<p>  \u041c\u0435\u0442\u043e\u0434\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0430\u043d\u0435\u0435 \u043c\u044b \u0435\u0449\u0435 \u043d\u0438\u0433\u0434\u0435 \u043d\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u043b\u0438:  <\/p>\n<pre><code class=\"objectivec\">- (NSURL *)applicationDocumentsDirectory{    return [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject]; } <\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"objectivec\">- (void)saveContext {    NSError *error = nil;    NSManagedObjectContext *managedObjectContext = [self managedObjectContext];     if(managedObjectContext != nil) {       if([managedObjectContext hasChanges] && ![managedObjectContext save:&error]){          NSLog(@&quot;Unresolved error %@, %@&quot;, error, [error userInfo]);          abort();       }    } } <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u043b\u0438 Core Data, \u043d\u0430\u0448\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043c\u043e\u0436\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445. <br \/>  \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043f\u0440\u0438\u043c\u0435\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u044b \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u043b \u043d\u0430\u043c \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0432\u0441\u0451 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0442\u0430\u043a, \u043a\u0430\u043a \u043d\u0430\u0434\u043e \u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u044e\u0442\u0441\u044f.<br \/>  \u0412 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u043a\u043e\u043b-\u0432\u043e \u0440\u0430\u0437, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0431\u044b\u043b\u043e \u0437\u0430\u043f\u0443\u0449\u0435\u043d\u043e \u043d\u0430\u0448\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435.<br \/>  \u0412\u043d\u0435\u0441\u0451\u043c \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432 \u043c\u0435\u0442\u043e\u0434 application:didFinishLaunchingWithOptions: \u0434\u0435\u043b\u0435\u0433\u0430\u0442\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0432 \u0432\u0438\u0434\u0435 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043a\u043e\u043b-\u0432\u0430 \u0440\u0430\u0437, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u043b\u043e\u0441\u044c \u0440\u0430\u043d\u0435\u0435 \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043d\u043e\u0432\u043e\u0433\u043e \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430.<\/p>\n<p>  \u041a\u043e\u0434 \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0445 \u0437\u0430\u043f\u0443\u0441\u043a\u043e\u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f:  <\/p>\n<pre><code class=\"objectivec\">NSManagedObjectContext *context = [self managedObjectContext]; NSFetchRequest *request = [[NSFetchRequest alloc] init]; NSEntityDescription *entity = [NSEntityDescription entityForName:@&quot;MyData&quot; inManagedObjectContext:context]; [request setEntity:entity]; NSArray *results = [context executeFetchRequest:request error:nil]; <\/code><\/pre>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0440\u043e\u0439\u0442\u0438\u0441\u044c \u043f\u043e \u0432\u0441\u0435\u043c\u0443 \u043c\u0430\u0441\u0441\u0438\u0432\u0443 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:  <\/p>\n<pre><code class=\"objectivec\">for(NSManagedObject *object in results){    NSLog(@&quot;Found %@&quot;, [object valueForKey:@&quot;myAttribute&quot;]; } <\/code><\/pre>\n<p>  \u0414\u043e\u0431\u0430\u0432\u0438\u043c \u043d\u043e\u0432\u0443\u044e \u0437\u0430\u043f\u0438\u0441\u044c \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u043c:  <\/p>\n<pre><code class=\"objectivec\">NSString *launchTitle = [NSString stringWithFormat:@&quot;launch %d&quot;, [results count]]; NSManagedObject *object = [NSEntityDescription insertNewObjectForEntityForName:[entity name] inManagedObjectContext:context]; [object setValue:launchTitle forKey:@&quot;myAttribute&quot;]; [self saveContext]; NSLog(@&quot;Added : %@&quot;, launchTitle); <\/code><\/pre>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0432\u044b\u0432\u0435\u0434\u0435\u0442 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443:  <\/p>\n<pre><code class=\"objectivec\">2011\u201302-25 05:13:23.783 DemoApp[2299:207] Added: launch 0 <\/code><\/pre>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u0432\u0442\u043e\u0440\u043e\u0433\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430:  <\/p>\n<pre><code class=\"objectivec\">2011\u201302-25 05:15:48.883 DemoApp[2372:207] Found launch 0  2011\u201302-25 05:15:48.889 DemoApp[2372:207] Added: launch 1 <\/code><\/pre>\n<p>  \u041f\u043e\u043b\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u0432\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\">- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    NSManagedObjectContext *context = [self managedObjectContext];    NSFetchRequest *request = [[NSFetchRequest alloc] init];    NSEntityDescription *entity = [NSEntityDescription entytyForName:@&quot;MyData&quot; inManagedObjectContext:context];    [request setEntity:entity];    NSArray *results = [context executeFetchRequest:request error:nil];     for(NSManagedObject *object in results){       NSLog(@&quot;Found %@&quot;, [object valueForKey:@&quot;myAttribute&quot;]);    }     NSString *launchTitle = [NSString stringWithFormat:@&quot;launch %d&quot;, [results count]];    NSManagedObject *object = [NSEntityDescription insertNewObjectForEntityForName:[entity name] inManagedObjectContext:context];    [object setValue:launchTitle forKey:@&quot;myAttribute&quot;];    [self saveContext];    NSLog(@&quot;Added : %@&quot;, launchTitle);        [self.window makeKeyAndVisible];    return YES; } <\/code><\/pre>\n<h5>\u0412 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u0435<\/h5>\n<p>  \u041f\u0440\u043e\u0448\u0443 \u043e\u0431 \u043e\u0448\u0438\u0431\u043a\u0430\u0445 \u043d\u0435 \u043f\u0438\u0441\u0430\u0442\u044c \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445, \u043b\u0443\u0447\u0448\u0435 \u0441\u0440\u0430\u0437\u0443 \u0432 \u043b\u0438\u0447\u043d\u044b\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f.<\/p>\n<p>  \u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0442\u044c \u043b\u0438 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u044b? \u0415\u0441\u0442\u044c \u043b\u0438 \u0438\u043d\u0442\u0435\u0440\u0435\u0441 \u043a \u0434\u0430\u043d\u043d\u043e\u0439 \u0442\u0435\u043c\u0435?<\/p>\n<p>  \u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044e \u0437\u0430 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435!    \t<\/p>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/191334\/\"> http:\/\/habrahabr.ru\/post\/191334\/<\/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 <b>\u0432\u043e\u043b\u044c\u043d\u044b\u0439<\/b> \u043f\u0435\u0440\u0435\u0432\u043e\u0434 \u043a\u043d\u0438\u0433\u0438 \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 \u0441\u043a\u0430\u0447\u0430\u0442\u044c \u043f\u043e <a href=\"http:\/\/it-ebooks.info\/book\/1843\/\">\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:\/\/habr.habrastorage.org\/post_images\/884\/2d0\/182\/8842d018201f3945800282b64f1d7221.jpg\" alt=\"image\"\/><\/p>\n<p>  \u0421\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0435:  <\/p>\n<ul>\n<li> \u0413\u043b\u0430\u0432\u0430 \u21161. \u041f\u0440\u0438\u0441\u0442\u0443\u043f\u0430\u0435\u043c (\u041f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0447\u0430\u0441\u0442\u044c) <\/li>\n<li> \u0413\u043b\u0430\u0432\u0430 \u21162. \u0423\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u043c Core Data<\/li>\n<li> \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<\/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","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-191334","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/191334","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=191334"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/191334\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=191334"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=191334"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=191334"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}