{"id":202834,"date":"2013-11-20T04:00:03","date_gmt":"2013-11-20T00:00:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=202834"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=202834","title":{"rendered":"<span class=\"post_title\">\u0420\u0438\u0441\u043e\u0432\u0430\u043b\u043a\u0430 \u043d\u0430 Objective-C \u043f\u043e\u0434 iOS (30 \u0441\u0442\u0440\u043e\u043a)<\/span>"},"content":{"rendered":"<div class=\"content html_format\">   \t<img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/ed3\/c63\/380\/ed3c633801eb2fec17dbc75e94c29f4f.png\" align=\"right\"\/><br \/>  \u0417\u0434\u0440\u0430\u0432\u0441\u0442\u0432\u0443\u0439\u0442\u0435, \u0434\u043e\u0440\u043e\u0433\u0438\u0435 \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u0438 \u0425\u0430\u0431\u0440\u0430!<\/p>\n<p>  \u0412\u043e\u0442 \u0438 \u044f \u0440\u0435\u0448\u0438\u043b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0447\u0442\u043e-\u043d\u0438\u0431\u0443\u0434\u044c \u0438\u0437 \u0442\u0440\u0438\u0434\u0446\u0430\u0442\u0438 \u0441\u0442\u0440\u043e\u043a \u043d\u0430 \u0440\u043e\u0434\u043d\u043e\u043c Objective-C. \u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0432 \u043f\u0440\u044f\u043c\u043e\u043c \u044d\u0444\u0438\u0440\u0435 \u0438 \u043f\u0440\u044f\u043c\u043e \u0441\u0435\u0439\u0447\u0430\u0441 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0440\u0438\u0441\u043e\u0432\u0430\u043b\u043a\u0443 \u043f\u043e\u0434 iPhone \u0438 iPad, \u0443\u043b\u043e\u0436\u0438\u0432\u0448\u0438\u0441\u044c \u0432 30 \u0441\u0442\u0440\u043e\u043a \u043a\u043e\u0434\u0430.<br \/>  <a name=\"habracut\"><\/a><br \/>  \u0420\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0432 \u0444\u0430\u0439\u043b\u0435 <i>main.m<\/i> \u0434\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u043f\u043e\u0434\u0441\u0447\u0435\u0442\u0430 \u0441\u0442\u0440\u043e\u043a. \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043d\u043e\u0432\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442 \u2014 Single View Application \u2014 \u0438 \u0443\u0434\u0430\u043b\u044f\u0435\u043c \u0444\u0430\u0439\u043b\u044b \u043a\u043b\u0430\u0441\u0441\u043e\u0432 ViewController&#8217;a \u0438 AppDelegat&#8217;a, \u0442\u0430\u043a \u043a\u0430\u043a \u0438\u0445 \u043c\u044b \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0435\u043c \u0432 <i>main.m<\/i>. \u0421\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0432 Storyboard&#8217;e \u043e\u0442\u0432\u044f\u0437\u044b\u0432\u0430\u0435\u043c ViewController \u043e\u0442 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430. \u0427\u0442\u043e\u0431\u044b \u043d\u0435 \u043f\u0430\u0440\u0438\u0442\u044c\u0441\u044f \u0438\u0437-\u0437\u0430 \u0441\u0442\u0430\u0442\u0443\u0441 \u0431\u0430\u0440\u0430 \u2014 \u0443\u0431\u0438\u0440\u0430\u0435\u043c \u0435\u0433\u043e \u0432 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u0445, \u0430 \u0442\u0430\u043a \u0436\u0435 \u0444\u0438\u043a\u0441\u0438\u0440\u0443\u0435\u043c \u043e\u0440\u0438\u0435\u043d\u0442\u0430\u0446\u0438\u044e \u044d\u043a\u0440\u0430\u043d\u0430, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0432\u043e\u043b\u043d\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0430\u0441\u0447\u0435\u0442 \u043f\u043e\u0432\u043e\u0440\u043e\u0442\u043e\u0432 \u0434\u0435\u0432\u0430\u0439\u0441\u0430.<\/p>\n<p>  \u0421\u0435\u0439\u0447\u0430\u0441 <i>main.m<\/i> \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0416\u043c\u0438 \u043c\u0435\u043d\u044f!<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"objectivec\">\/\/ \/\/  main.m \/\/  LittleDrawer \/\/ \/\/  Created by Nikita Kolmogorov on 19.11.13. \/\/  Copyright (c) 2013 Nikita Kolmogorov. All rights reserved. \/\/  #import &lt;UIKit\/UIKit.h&gt;  #import &quot;AppDelegate.h&quot;  int main(int argc, char * argv[]) {     @autoreleasepool {         return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));     } } <\/code><\/pre>\n<\/div>\n<\/div>\n<p>  \u041e\u0447\u0435\u043d\u044c, \u043e\u0447\u0435\u043d\u044c \u0436\u0438\u0440\u043d\u043e! \u041f\u0440\u0438\u0432\u0435\u0434\u0435\u043c \u0435\u0433\u043e \u043a \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u043c\u0443 \u0432\u0438\u0434\u0443, \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u044f \u0442\u043e, \u0447\u0442\u043e \u043a\u043e\u0434 \u043c\u0435\u0436\u0434\u0443 {} \u043c\u043e\u0436\u043d\u043e \u043f\u0438\u0441\u0430\u0442\u044c \u0432 \u043e\u0434\u043d\u0443 \u0441\u0442\u0440\u043e\u043a\u0443. \u041f\u0440\u043e\u0441\u0442\u0438\u0442\u0435 \u2014 \u0438\u043d\u0430\u0447\u0435 \u0441\u043b\u043e\u0436\u043d\u043e \u0432\u043b\u0435\u0437\u0442\u044c \u0432 30 \u0441\u0442\u0440\u043e\u043a. \u0418\u0437\u043c\u0435\u043d\u0438\u043c <i>main.m<\/i>:<\/p>\n<pre><code class=\"objectivec\">#import &lt;UIKit\/UIKit.h&gt; int main(int argc, char * argv[]) {@autoreleasepool {return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));} } <\/code><\/pre>\n<p>  \u0412 \u0440\u0430\u0437\u044b \u043b\u0443\u0447\u0448\u0435! \u0412\u0435\u0441\u044c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 <i>main.m<\/i> \u0442\u0435\u043f\u0435\u0440\u044c \u0443\u043c\u0435\u0449\u0430\u0435\u0442\u0441\u044f \u0432 2 \u0441\u0442\u0440\u043e\u043a\u0438. \u041d\u043e \u043c\u044b \u0436\u0435 \u0443\u0434\u0430\u043b\u0438\u043b\u0438 AppDelegate. \u041f\u043e\u043f\u0440\u0430\u0432\u0438\u043c \u044d\u0442\u0443 \u043e\u043f\u043b\u043e\u0448\u043d\u043e\u0441\u0442\u044c. \u0424\u0430\u0439\u043b <i>main.m<\/i>:<\/p>\n<pre><code class=\"objectivec\">#import &lt;UIKit\/UIKit.h&gt; @interface AppDelegate : UIResponder &lt;UIApplicationDelegate&gt; @property (strong, nonatomic) UIWindow *window; @end @implementation AppDelegate @end int main(int argc, char * argv[]) {@autoreleasepool {return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));} } <\/code><\/pre>\n<p>  \u041e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0432\u0441\u0435\u0433\u043e 26 \u0441\u0442\u0440\u043e\u043a! \u0412\u044b\u0437\u043e\u0432 \u043f\u0440\u0438\u043d\u044f\u0442.<\/p>\n<p>  \u041e\u0434\u043d\u0430\u043a\u043e, AppDelegate, \u0432\u0441\u0435-\u0442\u0430\u043a\u0438, \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u043e\u043f\u0440\u0430\u0432\u0438\u0442\u044c: \u043d\u0443\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043d\u0430\u0448\u0443 \u0440\u0438\u0441\u043e\u0432\u0430\u043b\u043a\u0443 \u043d\u0430 rootViewController:<\/p>\n<pre><code class=\"objectivec\">@interface AppDelegate : UIResponder &lt;UIApplicationDelegate&gt; @property (strong, nonatomic) UIWindow *window; @end @implementation AppDelegate  - (void)applicationDidFinishLaunching:(UIApplication *)application {     [self.window.rootViewController.view addSubview:[[Drawer alloc] init]]; } @end <\/code><\/pre>\n<p>  \u0414\u043e\u0431\u0430\u0432\u0438\u043c \u043a\u043b\u0430\u0441\u0441 \u043d\u0430\u0448\u0435\u0439 \u0440\u0438\u0441\u043e\u0432\u0430\u043b\u043a\u0438, \u0438 <i>main.m<\/i> \u043f\u0440\u0438\u043e\u0431\u0440\u0435\u0442\u0430\u0435\u0442 \u0432\u0438\u0434:<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0416\u043c\u0438 \u043c\u0435\u043d\u044f!<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"objectivec\">#import &lt;UIKit\/UIKit.h&gt; @interface Drawer : UIView @end @implementation Drawer @end @interface AppDelegate : UIResponder &lt;UIApplicationDelegate&gt; @property (strong, nonatomic) UIWindow *window; @end @implementation AppDelegate - (void)applicationDidFinishLaunching:(UIApplication *)application {     [self.window.rootViewController.view addSubview:[[Drawer alloc] initWithFrame:self.window.rootViewController.view.frame]]; } @end int main(int argc, char * argv[]) {@autoreleasepool {return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));} } <\/code><\/pre>\n<\/div>\n<\/div>\n<p>  \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 9 \u0441\u0442\u0440\u043e\u043a, \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c 21 \u0441\u0442\u0440\u043e\u043a\u0430 \u043d\u0430 \u0440\u0438\u0441\u043e\u0432\u0430\u043d\u0438\u0435. \u0414\u043e\u0431\u0430\u0432\u0438\u043c \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u043f\u0443\u0442\u044c \u0440\u0438\u0441\u043e\u0432\u0430\u043d\u0438\u044f \u0438 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u0442\u0430\u0447-\u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b \u0434\u043b\u044f \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0432 \u043a\u043b\u0430\u0441\u0441 Drawer:<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0416\u043c\u0438 \u043c\u0435\u043d\u044f!<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"objectivec\">@implementation Drawer static NSMutableArray *route; - (void)drawRect:(CGRect)rect {     CGContextSetStrokeColorWithColor(UIGraphicsGetCurrentContext(), [UIColor whiteColor].CGColor);     CGContextMoveToPoint(UIGraphicsGetCurrentContext(),[route[0][0] intValue],[route[0][1] intValue]);     for (int i = 1; i &lt; [route count]; i++)         CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), [route[i][0] intValue], [route[i][1] intValue]);     CGContextStrokePath(UIGraphicsGetCurrentContext()); } - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {     route = [NSMutableArray array]; \t[route addObject:@[@([[touches anyObject]locationInView:self].x),@([[touches anyObject]locationInView:self].y)]]; } - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {     [route addObject:@[@([[touches anyObject]locationInView:self].x),@([[touches anyObject]locationInView:self].y)]];     [self setNeedsDisplay]; } @end <\/code><\/pre>\n<\/div>\n<\/div>\n<p>  \u041f\u0440\u043e\u0441\u0442\u043e \u0440\u0438\u0441\u0443\u0435\u043c \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u043f\u0443\u0442\u044c \u043f\u043e \u043f\u0440\u0438\u043a\u043e\u0441\u043d\u043e\u0432\u0435\u043d\u0438\u044f\u043c \u0438 \u043d\u0435 \u0437\u0430\u0431\u043e\u0442\u0438\u043c\u0441\u044f \u043e \u0443\u0436\u0435 \u043d\u0430\u0440\u0438\u0441\u043e\u0432\u0430\u043d\u043d\u043e\u043c. \u0424\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u0444\u0430\u0439\u043b <i>main.m<\/i> \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0416\u043c\u0438 \u043c\u0435\u043d\u044f!<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"objectivec\">#import &lt;UIKit\/UIKit.h&gt; @interface Drawer : UIView @end @implementation Drawer static NSMutableArray *route; - (void)drawRect:(CGRect)rect {     CGContextSetStrokeColorWithColor(UIGraphicsGetCurrentContext(), [UIColor whiteColor].CGColor);     CGContextMoveToPoint(UIGraphicsGetCurrentContext(),[route[0][0] intValue],[route[0][1] intValue]);     for (int i = 1; i &lt; [route count]; i++)         CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), [route[i][0] intValue], [route[i][1] intValue]);     CGContextStrokePath(UIGraphicsGetCurrentContext()); } - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {     route = [NSMutableArray array]; \t[route addObject:@[@([[touches anyObject]locationInView:self].x),@([[touches anyObject]locationInView:self].y)]]; } - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {     [route addObject:@[@([[touches anyObject]locationInView:self].x),@([[touches anyObject]locationInView:self].y)]];     [self setNeedsDisplay]; } @end @interface AppDelegate : UIResponder &lt;UIApplicationDelegate&gt; @property (strong, nonatomic) UIWindow *window; @end @implementation AppDelegate -(void)applicationDidFinishLaunching:(UIApplication *)application {     [self.window.rootViewController.view addSubview:[[Drawer alloc] initWithFrame:self.window.rootViewController.view.frame]]; } @end int main(int argc, char * argv[]) {@autoreleasepool {return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));} } <\/code><\/pre>\n<\/div>\n<\/div>\n<p>  \u0420\u043e\u0432\u043d\u043e 30 \u0441\u0442\u0440\u043e\u043a \u043a\u043e\u0434\u0430 \u043d\u0430 Objective-C. \u0412\u043e\u0442 \u0438 \u0432\u0441\u0435! \u041c\u043d\u0435 \u0434\u0430\u0436\u0435 \u043f\u043e\u0447\u0442\u0438 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c \u0441\u0432\u043e\u0435\u0439 \u0441\u0442\u0438\u043b\u0438\u0441\u0442\u0438\u043a\u0435 \u043a\u043e\u0434\u0430. \u0415\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435, \u043d\u0430 \u0447\u0442\u043e \u043d\u0435 \u0445\u0432\u0430\u0442\u0438\u043b\u043e \u0441\u0442\u0440\u043e\u043a \u2014 \u044d\u0442\u043e \u0440\u0430\u0441\u043f\u0438\u0441\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e main.<\/p>\n<p>  GitHub:<br \/>  <a href=\"https:\/\/github.com\/backmeupplz\/LittleDrawer\/\">github.com\/backmeupplz\/LittleDrawer\/<\/a><\/p>\n<p>  Instacode:  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0416\u043c\u0438 \u043c\u0435\u043d\u044f!<\/b><\/p>\n<div class=\"spoiler_text\"><a href=\"http:\/\/instacod.es\/83377\">instacod.es\/83377<\/a><\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/8a2\/5bb\/b15\/8a25bbb1562809d1d7b776f0625b97f9.png\" alt=\"image\"\/>  <\/div>\n<\/div>\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\/202834\/\"> http:\/\/habrahabr.ru\/post\/202834\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">   \t<img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/ed3\/c63\/380\/ed3c633801eb2fec17dbc75e94c29f4f.png\" align=\"right\"\/><br \/>  \u0417\u0434\u0440\u0430\u0432\u0441\u0442\u0432\u0443\u0439\u0442\u0435, \u0434\u043e\u0440\u043e\u0433\u0438\u0435 \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u0438 \u0425\u0430\u0431\u0440\u0430!<\/p>\n<p>  \u0412\u043e\u0442 \u0438 \u044f \u0440\u0435\u0448\u0438\u043b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0447\u0442\u043e-\u043d\u0438\u0431\u0443\u0434\u044c \u0438\u0437 \u0442\u0440\u0438\u0434\u0446\u0430\u0442\u0438 \u0441\u0442\u0440\u043e\u043a \u043d\u0430 \u0440\u043e\u0434\u043d\u043e\u043c Objective-C. \u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0432 \u043f\u0440\u044f\u043c\u043e\u043c \u044d\u0444\u0438\u0440\u0435 \u0438 \u043f\u0440\u044f\u043c\u043e \u0441\u0435\u0439\u0447\u0430\u0441 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0440\u0438\u0441\u043e\u0432\u0430\u043b\u043a\u0443 \u043f\u043e\u0434 iPhone \u0438 iPad, \u0443\u043b\u043e\u0436\u0438\u0432\u0448\u0438\u0441\u044c \u0432 30 \u0441\u0442\u0440\u043e\u043a \u043a\u043e\u0434\u0430.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-202834","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/202834","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=202834"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/202834\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=202834"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=202834"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=202834"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}