{"id":170265,"date":"2013-02-22T20:10:03","date_gmt":"2013-02-22T16:10:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=170265"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=170265","title":{"rendered":"<span class=\"post_title\">\u0410\u043d\u043e\u043d\u0438\u043c\u043d\u044b\u0435 \u043a\u043b\u0430\u0441\u0441\u044b \u0432 Objective-C<\/span>"},"content":{"rendered":"<div class=\"content html_format\">   \t\u0414\u0430\u043d\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0435\u043d\u0438\u0435\u043c <a href=\"http:\/\/habrahabr.ru\/post\/168105\/\">\u00ab\u041f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043c\u0435\u0442\u043e\u0434\u0430. \u0412\u0434\u043e\u0445\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u0439 Java&#8217;\u043e\u0439\u00bb<\/a>. \u0412 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0437\u0430\u043c\u0435\u0442\u043a\u0435 \u0431\u044b\u043b\u043e \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u043e \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0443\u0436 \u043a\u0440\u0438\u0432\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435, \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0432 \u0442\u0430\u043a\u043e\u043c \u0432\u0438\u0434\u0435 \u043d\u0435 \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0438 \u0431\u044b\u043b\u043e \u043f\u0440\u0438\u043d\u044f\u0442\u043e \u0432\u043e\u043b\u0435\u0432\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0434\u043e\u0432\u0435\u0441\u0442\u0438 \u0441\u0432\u043e\u0435 \u043d\u0430\u0447\u0438\u043d\u0430\u043d\u0438\u0435 \u0434\u043e \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u0438 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432\u0441\u0435 \u00ab\u043a\u0430\u043a \u043d\u0430\u0434\u043e\u00bb. \u0425\u043e\u0442\u044f \u0432\u043e\u043f\u0440\u043e\u0441 \u043d\u0443\u0436\u043d\u043e\u0441\u0442\u0438 \u0442\u0430\u043a\u043e\u0433\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u0430 \u0432 Objective-C \u0434\u043e \u0441\u0438\u0445 \u043f\u043e\u0440 \u043e\u0442\u043a\u0440\u044b\u0442.<\/p>\n<p>  \u0418\u0442\u0430\u043a, \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0435\u043c \u0431\u044b\u0442\u044c \u043f\u043e\u0445\u043e\u0436\u0438\u043c\u0438 \u043d\u0430 Java<br \/>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/d40\/3a2\/ce2\/d403a2ce2d98696e11547d6190299305.jpg\"\/><br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<h4>\u0422\u0435\u043e\u0440\u0438\u044f <a href=\"http:\/\/ru.wikipedia.org\/wiki\/\u0412\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0439_\u043a\u043b\u0430\u0441\u0441#.D0.90.D0.BD.D0.BE.D0.BD.D0.B8.D0.BC.D0.BD.D1.8B.D0.B5_.28.D0.B1.D0.B5.D0.B7.D1.8B.D0.BC.D1.8F.D0.BD.D0.BD.D1.8B.D0.B5.29_.D0.BA.D0.BB.D0.B0.D1.81.D1.81.D1.8B\">\u0410\u043d\u043e\u043d\u0438\u043c\u043d\u044b\u0435 (\u0431\u0435\u0437\u044b\u043c\u044f\u043d\u043d\u044b\u0435) \u043a\u043b\u0430\u0441\u0441\u044b<\/a><\/h4>\n<p>  \u0414\u0435\u043a\u043b\u0430\u0440\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0432\u043d\u0443\u0442\u0440\u0438 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430. \u041c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u043d\u0443\u0442\u0440\u0438 \u044d\u0442\u0438\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432. \u0412 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432, \u0430\u043d\u043e\u043d\u0438\u043c\u043d\u044b\u0435 \u043a\u043b\u0430\u0441\u0441\u044b \u043d\u0435 \u0438\u043c\u0435\u044e\u0442 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f. \u0413\u043b\u0430\u0432\u043d\u043e\u0435 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u0435 \u043a \u0430\u043d\u043e\u043d\u0438\u043c\u043d\u043e\u043c\u0443 \u043a\u043b\u0430\u0441\u0441\u0443 \u2014 \u043e\u043d \u0434\u043e\u043b\u0436\u0435\u043d \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u043a\u043b\u0430\u0441\u0441 \u0438\u043b\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441. \u041d\u0435 \u043c\u043e\u0433\u0443\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 (\u043d\u043e \u043c\u043e\u0433\u0443\u0442 \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c) \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043f\u043e\u043b\u0435\u0439, \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0438 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 (\u043a\u0440\u043e\u043c\u0435 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442). \u041f\u0440\u0438\u043c\u0435\u0440:  <\/p>\n<pre><code class=\"java\">class OuterClass {    public OuterClass() {}    void methodWithLocalClass (final int interval)    {       \/\/ \u041f\u0440\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0438 \u0430\u043d\u043e\u043d\u0438\u043c\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d \u043f\u043e\u043b\u0438\u043c\u043e\u0440\u0444\u0438\u0437\u043c - \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f listener        \/\/ \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u0430\u043d\u043e\u043d\u0438\u043c\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430, \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0449\u0435\u0433\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439        \/\/ \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 ActionListener       ActionListener listener = new ActionListener()       {          public void actionPerformed(ActionEvent event)          {             System.out.println(&quot;\u042d\u0442\u0430 \u0441\u0442\u0440\u043e\u043a\u0430 \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043d\u0430 \u044d\u043a\u0440\u0430\u043d \u043a\u0430\u0436\u0434\u044b\u0435 &quot; + interval + &quot; \u0441\u0435\u043a\u0443\u043d\u0434&quot;);          }         };         Timer t = new Timer(interval, listener); \/\/ \u041e\u0431\u044a\u0435\u043a\u0442 \u0430\u043d\u043e\u043d\u0438\u043c\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d \u0432\u043d\u0443\u0442\u0440\u0438 \u043c\u0435\u0442\u043e\u0434\u0430       t.start();    } } <\/code><\/pre>\n<p>  \u041a\u043e\u043d\u0435\u0447\u043d\u043e \u0436\u0435, \u0432 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u043d\u043e\u0439 \u043d\u0438\u0436\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u044e\u0442 \u0442\u0430\u043a\u0438\u0435 \u0441\u0442\u0440\u043e\u0433\u0438\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f, \u043d\u0430\u0432\u0435\u0440\u043d\u043e\u0435 \u0434\u0430\u0436\u0435 \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442.<\/p>\n<h4>\u041f\u0440\u0438\u043c\u0435\u0440\u044b<\/h4>\n<p>   \u041a\u0430\u043a \u0438 \u0432 \u043f\u0440\u043e\u0448\u043b\u044b\u0439 \u0440\u0430\u0437, \u043d\u0430\u0447\u043d\u0435\u043c \u0441 \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u0438. \u0411\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 \u0438\u0437 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u0442\u0430\u043a \u0436\u0435 \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u044b, \u043d\u043e \u0441 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u043e\u0433\u043e\u0432\u043e\u0440\u043a\u0430\u043c\u0438   <\/p>\n<h6>1) \u041f\u0440\u0438\u043c\u0435\u0440 \u0441 \u0434\u0435\u043b\u0435\u0433\u0430\u0442\u043e\u043c \u0434\u043b\u044f UITableView<\/h6>\n<p>  <\/p>\n<pre><code class=\"objectivec\"> id&lt;UITableViewDelegate&gt; delegate =[[NSObject alloc] init:^{          ADD_METHOD(@selector(tableView:didSelectRowAtIndexPath:),                    @protocol(UITableViewDelegate),                    NO,                    ^(id selfObj,UITableView* tv,NSIndexPath* path)                    {                        NSLog(@&quot;did select row %i&quot;,path.row);                    });         ADD_METHOD(@selector(tableView:willSelectRowAtIndexPath:),                    @protocol(UITableViewDelegate),                    NO,                    ^NSIndexPath*(id selfObj,UITableView* tv,NSIndexPath* path)                    {                        NSLog(@&quot;will select row %i&quot;,path.row);                        return path;                    });     }]; self.tableView.delegate = delegate; <\/code><\/pre>\n<p>  <\/p>\n<h6>2) \u0414\u0443\u0440\u0430\u0447\u0435\u0441\u0442\u0432\u043e<\/h6>\n<p>  <\/p>\n<pre><code class=\"objectivec\"> NSString *str = [@&quot;Go&quot; overrideMethod:@selector(description) blockImp:^NSString*(){       return @&quot;Stop&quot;;  }];  NSLog(@&quot;%@&quot;,str); \/\/\/log: Stop <\/code><\/pre>\n<p>  <\/p>\n<h6>3) \u041b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043d\u043e\u0432\u044b\u0445 item \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u044e\u0449\u0438\u0439 \u043d\u0430\u0441 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440<\/h6>\n<p>  <\/p>\n<pre><code class=\"objectivec\">    NSMutableArray * array1 = [NSMutableArray arrayWithCapacity:10];     NSMutableArray * array2= [NSMutableArray arrayWithCapacity:10];     [array2 modifyMethods:^{         OVERRIDE(@selector(addObject:),                  ^(id arr,id anObject1)                  {                      NSLog(@&quot;%@&quot;,[anObject1 description]);                      \/\/[super addObject:anObject1]                      objc_msgSendSuper(SUPER(arr), @selector(addObject:),anObject1);                  });         OVERRIDE(@selector(insertObject:atIndex:),                  ^(id arr,id anObject,NSUInteger index)                  {                      NSLog(@&quot;%@&quot;,[anObject description]);                      \/\/[super insertObject:anObject atIndex:index];                      objc_msgSendSuper(SUPER(arr), @selector(insertObject:atIndex:),anObject,index);                                        });     }];     [array1 addObject:@&quot;Test&quot;];     [array2 addObject:@&quot;One&quot;];     [array2 addObject:@&quot;Two&quot;];  Log: \/\/\u041f\u043e\u0432\u0442\u043e\u0440\u0435\u043d\u0438\u0435 \u0441\u0432\u044f\u0437\u0430\u043d\u043e \u0441 \u0442\u0435\u043c, \u0447\u0442\u043e \u043c\u0435\u0442\u043e\u0434 addObject: \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 insertObject:atIndex  One  One  Two  Two <\/code><\/pre>\n<h4>\u041a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442<\/h4>\n<p>  \u041f\u0440\u0438 \u0432\u044b\u0437\u043e\u0432\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \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 \u043d\u043e\u0432\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u0441 \u0438\u043c\u0435\u043d\u0435\u043c <i>&lt;\u0441\u0442\u0430\u0440\u044b\u0439 \u043a\u043b\u0430\u0441\u0441&gt;_anon_&lt;\u043d\u043e\u043c\u0435\u0440 \u0430\u043d\u043e\u043d\u0438\u043c\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430&gt; <\/i> (\u043f\u0440\u0438\u043c\u0435\u0440 <i>NSString_anon_3<\/i>), \u0443\u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043e\u0442 \u043a\u043b\u0430\u0441\u0441\u0430 \u043e\u0431\u044a\u0435\u043a\u0442\u0430. \u041a\u043b\u0430\u0441\u0441 \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u043d\u0430 \u043d\u043e\u0432\u044b\u0439. \u0421\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u043a\u043e\u0434:    <\/p>\n<pre><code class=\"objectivec\">        \/\/\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c \u0432 runtime \u043d\u043e\u0432\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u0441 \u0438\u043c\u0435\u043d\u0435\u043c newClassStr, \u0443\u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u043c \u0435\u0433\u043e \u043e\u0442 [self class]         newClass = objc_allocateClassPair([self class], [newClassStr UTF8String], 0);         \/\/\u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c \u043c\u0435\u0442\u043e\u0434\u044b \u0443 \u043a\u043b\u0430\u0441\u0441\u0430 newClass: \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u043d\u043e\u0432\u0443\u044e IMP \u0438\u043b\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c Method         ....         \/\/\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u043c \u043a\u043b\u0430\u0441\u0441         objc_registerClassPair(newClass);         \/\/\u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c \u043a\u043b\u0430\u0441\u0441 \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430         object_setClass(self, newClass); <\/code><\/pre>\n<p>  \u0418 \u0432\u0441\u0435. <\/p>\n<h4>\u041a\u0430\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c<\/h4>\n<p>  \u041a\u0430\u043a \u0438 \u0440\u0430\u043d\u044c\u0448\u0435, \u0435\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043c\u0435\u0442\u043e\u0434\u0430, \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c:   <\/p>\n<pre><code class=\"objectivec\">-(id) addMethod:(SEL)sel fromProtocol:(Protocol *)p isRequired:(BOOL)isReq blockImp:(id)block; -(id) overrideMethod:(SEL)sel blockImp:(id)block; <\/code><\/pre>\n<p>  \u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435: \u043a\u043b\u0430\u0441\u0441 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043c\u0435\u043d\u0435\u043d \u043d\u0430 \u0430\u043d\u043e\u043d\u0438\u043c\u043d\u044b\u0439.<br \/>  \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u0435\u0441\u043b\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c\/\u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0442\u043e \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c  <\/p>\n<pre><code class=\"objectivec\">- (id)modifyMethods:(void(^)())blockOv; <\/code><\/pre>\n<p>  blockOv \u2014 \u0431\u043b\u043e\u043a, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0439 \u0432\u044b\u0437\u043e\u0432\u044b \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 C-\u0444\u0443\u043d\u043a\u0446\u0438\u0439:  <\/p>\n<pre><code class=\"cpp\">\/\/\u041f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043c\u0435\u0442\u043e\u0434 sel c \u043d\u043e\u0432\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0435\u0439 blockIMP  BOOL OVERRIDE(SEL sel,id blockIMP);  \/\/\u041f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043d\u043e\u0432\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 sel, \u0441 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435\u043c \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u044b \u0432 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0435 p \u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0435\u0439 blockIMP BOOL ADD_METHOD(SEL sel,Protocol *p, BOOL isReq, id blockIMP); \/\/\u041f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043d\u043e\u0432\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 sel, \u0441 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435\u043c \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u044b \u0432 \u043a\u043b\u0430\u0441\u0441\u0435 \u0441 \u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0435\u0439 blockIMP BOOL ADD_METHOD_C(SEL sel,Class c,id blockIMP); <\/code><\/pre>\n<p>  \u0412\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0434\u0430\u043d\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0432\u044b\u0437\u0432\u0430\u043d\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0431\u043b\u043e\u043a\u0435 blockOv \u043c\u0435\u0442\u043e\u0434\u043e\u0432 -modifyMethods:^,-init:^,+new:^.<br \/>  \u0422\u0430\u043a \u0436\u0435 \u0432 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u044e NSObject \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u044b \u043c\u0435\u0442\u043e\u0434\u044b +(id)new:^ \u0438 +(id)init, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0435 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0430\u043d\u043e\u043d\u0438\u043c\u043d\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u043f\u043e\u0445\u043e\u0436\u0438\u043c \u043d\u0430 Java:  <\/p>\n<pre><code class=\"java\">Button.OnClickListener mTakePicSOnClickListener =  new Button.OnClickListener() {         @Override         public void onClick(View v) {               \/\/body         }     }; <\/code><\/pre>\n<pre><code class=\"objectivec\">UIOnClickListener *listener =[UIOnClickListener new:^{                     OVERRIDE(@selector(onClick:), ^void(id selfObj,UIButton* sender){                               \/\/body                           });                 }]; <\/code><\/pre>\n<p>  \u0421\u043a\u0430\u0447\u0430\u0442\u044c \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442 \u0438 \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u0441\u044f \u0441 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0435\u0439 \u043c\u043e\u0436\u043d\u043e \u0442\u0443\u0442: github.com\/Flanker4\/MMMutableMethods\/<\/p>\n<h4>\u0417\u0430\u043c\u0435\u0442\u043a\u0438 \u043d\u0430 \u043f\u043e\u043b\u044f\u0445<\/h4>\n<p>  \u041e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u0445\u043e\u0447\u0443 \u0443\u043f\u043e\u043c\u044f\u043d\u0443\u0442\u044c \u043e Sergey Starukhin (pingvin4eg \u043d\u0430 github).<br \/>  \u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u043c <a href=\"http:\/\/habrahabr.ru\/users\/bsideup\/\" class=\"user_link\">bsideup<\/a>, <a href=\"http:\/\/habrahabr.ru\/users\/firexel\/\" class=\"user_link\">firexel<\/a> \u0438 \u0433\u0443\u0433\u043b\u0443 \u0441\u0442\u0430\u043b\u043e \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u0430\u043d\u043e\u043d\u0438\u043c\u043d\u044b\u0435 \u043a\u043b\u0430\u0441\u0441\u044b \u0438 \u043a\u0430\u043a \u043e\u043d\u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0432 Java. \u042f \u0434\u0430\u0436\u0435 \u043f\u0440\u0438\u043d\u044f\u043b\u0441\u044f \u0437\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e, \u043d\u043e \u0432\u0434\u0440\u0443\u0433 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u043b \u0444\u043e\u0440\u043a \u0421\u0435\u0440\u0433\u0435\u044f \u043d\u0430 \u0433\u0438\u0442\u0445\u0430\u0431\u0435 \u0441 \u0433\u043e\u0442\u043e\u0432\u043e\u0439 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0435\u0439 \u043a\u043b\u0430\u0441\u0441\u043e\u0432. \u042f \u0437\u0430\u043d\u044f\u043b \u0432\u044b\u0436\u0438\u0434\u0430\u044e\u0449\u0443\u044e \u043f\u043e\u0437\u0438\u0446\u0438\u044e \u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043b\u0435\u0434\u0438\u0442, \u043e\u0436\u0438\u0434\u0430\u044f \u0447\u0442\u043e \u0421\u0435\u0440\u0433\u0435\u0439 \u043b\u0438\u0431\u043e \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u0442 \u043d\u0430\u0447\u0430\u0442\u043e\u0435, \u043b\u0438\u0431\u043e \u0436\u0435 \u0441\u0434\u0435\u043b\u0430\u0435\u0442 pull request. \u041d\u043e \u043a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e \u043e\u043d \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043b \u0434\u0435\u043b\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0435 \u043a\u043e\u043c\u043c\u0438\u0442\u044b, \u0430 \u043f\u043e\u043f\u044b\u0442\u043a\u0430 \u0441\u0432\u044f\u0437\u0430\u0442\u044c\u0441\u044f \u0441 \u043d\u0438\u043c \u043f\u043e\u0442\u0435\u0440\u043f\u0435\u043b\u0430 \u043d\u0435\u0443\u0434\u0430\u0447\u0443 (\u043f\u043e\u043f\u0440\u0430\u0432\u043a\u0430: \u0433\u0438\u0442\u0445\u0430\u0431 \u043d\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043d\u0430 \u043f\u0440\u044f\u043c\u0443\u044e user&#8217;\u0443 \u0438 \u044f \u043f\u0440\u043e\u0441\u0442\u043e \u0443\u043f\u043e\u043c\u044f\u043d\u0443\u043b \u0435\u0433\u043e \u043d\u0438\u043a \u0432 \u043e\u0434\u043d\u043e\u043c \u0438\u0437 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0435\u0432, \u0441 \u043f\u0440\u043e\u0441\u044c\u0431\u043e\u0439 \u0441\u0432\u044f\u0437\u0430\u0442\u044c\u0441\u044f \u0441\u043e \u043c\u043d\u043e\u0439 \u0447\u0435\u0440\u0435\u0437 \u0445\u0430\u0431\u0440. \u0415\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u044f \u0436\u0434\u0430\u043b \u041b\u0421 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043d\u0430 Habrahabr \u0438 \u043d\u0435 \u0441\u0442\u0430\u043b \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u0442\u044c \u0432\u0435\u0442\u043a\u0443 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0435\u0432 \u043d\u0430 \u0433\u0438\u0442\u0445\u0430\u0431\u0435. \u041a\u0430\u043a \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u0437\u0440\u044f, \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0443\u0434\u0430 \u0438 \u043e\u0442\u0432\u0435\u0442\u0438\u043b \u0421\u0435\u0440\u0433\u0435\u0439, \u0443 \u043d\u0435\u0433\u043e \u043f\u043e\u043f\u0440\u043e\u0441\u0442\u0443 \u043d\u0435 \u0431\u044b\u043b\u043e \u0430\u043a\u043a\u0430\u0443\u043d\u0442\u0430 \u043d\u0430 \u0445\u0430\u0431\u0440\u0435&#8230;). \u0412 \u0438\u0442\u043e\u0433\u0435 \u044f \u0441\u0434\u0435\u043b\u0430\u043b \u0441\u0432\u043e\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e, \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u043d\u0443\u044e \u043d\u0430 \u043a\u043e\u0434\u0435 \u0421\u0435\u0440\u0433\u0435\u044f, \u0441 \u0442\u0430\u043a\u0438\u043c\u0438 \u0444\u0438\u0447\u0430\u043c\u0438 \u043a\u0430\u043a \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u043e\u0432, \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u043a\u0443\u0447\u0438 \u0430\u043d\u043e\u043d\u0438\u043c\u043d\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432, \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c, \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0438 \u043f\u0440). \u0415\u0441\u043b\u0438 \u0443 \u043a\u043e\u0433\u043e-\u0442\u043e \u0437\u0430\u0432\u0430\u043b\u044f\u043b\u0441\u044f \u043b\u0438\u0448\u043d\u0438\u0439 \u0438\u043d\u0432\u0430\u0439\u0442 \u0438 \u044d\u0442\u043e\u0442 \u043a\u0442\u043e-\u0442\u043e \u0441\u0447\u0438\u0442\u0430\u0435\u0442 \u0447\u0442\u043e \u0421\u0435\u0440\u0433\u0435\u0439 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u043e\u043b\u0435\u0437\u0435\u043d \u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u0443, \u0442\u043e \u043d\u0430\u043f\u0438\u0448\u0438\u0442\u0435 \u043c\u043d\u0435 \u041b\u0421 \u0438 \u044f \u0432\u044b\u0448\u043b\u044e \u0435\u0433\u043e \u043a\u043e\u043d\u0442\u0430\u043a\u0442\u043d\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u0412\u0430\u043c.    \t \t\t   \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\/170265\/\"> http:\/\/habrahabr.ru\/post\/170265\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">   \t\u0414\u0430\u043d\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0435\u043d\u0438\u0435\u043c <a href=\"http:\/\/habrahabr.ru\/post\/168105\/\">\u00ab\u041f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043c\u0435\u0442\u043e\u0434\u0430. \u0412\u0434\u043e\u0445\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u0439 Java&#8217;\u043e\u0439\u00bb<\/a>. \u0412 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0437\u0430\u043c\u0435\u0442\u043a\u0435 \u0431\u044b\u043b\u043e \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u043e \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0443\u0436 \u043a\u0440\u0438\u0432\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435, \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0432 \u0442\u0430\u043a\u043e\u043c \u0432\u0438\u0434\u0435 \u043d\u0435 \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0438 \u0431\u044b\u043b\u043e \u043f\u0440\u0438\u043d\u044f\u0442\u043e \u0432\u043e\u043b\u0435\u0432\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0434\u043e\u0432\u0435\u0441\u0442\u0438 \u0441\u0432\u043e\u0435 \u043d\u0430\u0447\u0438\u043d\u0430\u043d\u0438\u0435 \u0434\u043e \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u0438 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432\u0441\u0435 \u00ab\u043a\u0430\u043a \u043d\u0430\u0434\u043e\u00bb. \u0425\u043e\u0442\u044f \u0432\u043e\u043f\u0440\u043e\u0441 \u043d\u0443\u0436\u043d\u043e\u0441\u0442\u0438 \u0442\u0430\u043a\u043e\u0433\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u0430 \u0432 Objective-C \u0434\u043e \u0441\u0438\u0445 \u043f\u043e\u0440 \u043e\u0442\u043a\u0440\u044b\u0442.<\/p>\n<p>  \u0418\u0442\u0430\u043a, \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0435\u043c \u0431\u044b\u0442\u044c \u043f\u043e\u0445\u043e\u0436\u0438\u043c\u0438 \u043d\u0430 Java<br \/>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/d40\/3a2\/ce2\/d403a2ce2d98696e11547d6190299305.jpg\"\/>  <\/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-170265","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/170265","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=170265"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/170265\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=170265"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=170265"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=170265"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}