Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/errors'
- Loading branch information
Showing
8 changed files
with
650 additions
and
563 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// NSInvocation+blocks.h - http://github.com/rentzsch/NSInvocation-blocks | ||
// Copyright (c) 2010 Jonathan 'Wolf' Rentzsch: http://rentzsch.com | ||
// Some rights reserved: http://opensource.org/licenses/mit-license.php | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
@interface NSInvocation (Blocks) | ||
|
||
/* | ||
Usage example: | ||
NSInvocation *invocation = [NSInvocation jr_invocationWithTarget:myObject block:^(id myObject){ | ||
[myObject someMethodWithArg:42.0]; | ||
}]; | ||
*/ | ||
|
||
+ (id)jr_invocationWithTarget:(id)target block:(void (^)(id target))block; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// NSInvocation+blocks.m - http://github.com/rentzsch/NSInvocation-blocks | ||
// Copyright (c) 2010 Jonathan 'Wolf' Rentzsch: http://rentzsch.com | ||
// Some rights reserved: http://opensource.org/licenses/mit-license.php | ||
|
||
#import "NSInvocation+Blocks.h" | ||
|
||
@interface JRInvocationGrabber : NSProxy { | ||
id target; | ||
NSInvocation *invocation; | ||
} | ||
@property (retain) id target; | ||
@property (retain) NSInvocation *invocation; | ||
@end | ||
|
||
@implementation JRInvocationGrabber | ||
@synthesize target, invocation; | ||
|
||
- (id)initWithTarget:(id)target_ { | ||
self.target = target_; | ||
return self; | ||
} | ||
|
||
- (NSMethodSignature*)methodSignatureForSelector:(SEL)selector_ { | ||
return [self.target methodSignatureForSelector:selector_]; | ||
} | ||
|
||
- (void)forwardInvocation:(NSInvocation*)invocation_ { | ||
[invocation_ setTarget:self.target]; | ||
self.invocation = invocation_; | ||
} | ||
|
||
- (void)dealloc { | ||
self.target = nil; | ||
self.invocation = nil; | ||
} | ||
@end | ||
|
||
|
||
@implementation NSInvocation (jr_block) | ||
|
||
+ (id)jr_invocationWithTarget:(id)target_ block:(void (^)(id target))block_ { | ||
JRInvocationGrabber *grabber = [[JRInvocationGrabber alloc] initWithTarget:target_]; | ||
block_(grabber); | ||
return grabber.invocation; | ||
} | ||
|
||
@end |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,5 @@ | |
|
||
#ifdef __OBJC__ | ||
#import <Foundation/Foundation.h> | ||
#import "NSInvocation+blocks.h" | ||
#endif |