Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/errors'
Browse files Browse the repository at this point in the history
  • Loading branch information
Owain R Hunt committed Apr 7, 2012
2 parents 3de808f + 404fc11 commit 0c7c29d
Show file tree
Hide file tree
Showing 8 changed files with 650 additions and 563 deletions.
19 changes: 19 additions & 0 deletions Classes/NSInvocation+Blocks.h
@@ -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
47 changes: 47 additions & 0 deletions Classes/NSInvocation+Blocks.m
@@ -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
369 changes: 184 additions & 185 deletions Classes/UAGithubEngine.h

Large diffs are not rendered by default.

767 changes: 392 additions & 375 deletions Classes/UAGithubEngine.m

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Classes/UAGithubURLConnection.h
Expand Up @@ -23,6 +23,6 @@
@property (nonatomic, assign) UAGithubResponseType responseType;
@property (nonatomic, strong) NSString *identifier;

+ (id)asyncRequest:(NSURLRequest *)request success:(id(^)(NSData *, NSURLResponse *))successBlock_ failure:(id(^)(NSError *))failureBlock_;
+ (id)asyncRequest:(NSURLRequest *)request success:(id(^)(NSData *, NSURLResponse *))successBlock failure:(id(^)(NSError *))failureBlock_;

@end
4 changes: 2 additions & 2 deletions Classes/UAGithubURLConnection.m
Expand Up @@ -14,7 +14,7 @@ @implementation UAGithubURLConnection

@synthesize data, requestType, responseType, identifier;

+ (id)asyncRequest:(NSURLRequest *)request success:(id(^)(NSData *, NSURLResponse *))successBlock_ failure:(id(^)(NSError *))failureBlock_
+ (id)asyncRequest:(NSURLRequest *)request success:(id(^)(NSData *, NSURLResponse *))successBlock failure:(id(^)(NSError *))failureBlock_
{
// This has to be dispatch_sync rather than _async, otherwise our successBlock executes before the request is done and we're all bass-ackwards.
//dispatch_sync(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
Expand All @@ -30,7 +30,7 @@ + (id)asyncRequest:(NSURLRequest *)request success:(id(^)(NSData *, NSURLRespons
if (error) {
return failureBlock_(error);
} else {
return successBlock_(data,response);
return successBlock(data,response);
}
}

Expand Down
4 changes: 4 additions & 0 deletions UAGithubEngine.xcodeproj/project.pbxproj
Expand Up @@ -53,6 +53,8 @@
CC12924215029A5300904FA5 /* UAGithubURLConnection.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UAGithubURLConnection.m; sourceTree = "<group>"; };
CC12924315029A5300904FA5 /* UAReachability.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UAReachability.h; sourceTree = "<group>"; };
CC12924415029A5300904FA5 /* UAReachability.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UAReachability.m; sourceTree = "<group>"; };
CC274113152F885C00E946AD /* NSInvocation+blocks.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "NSInvocation+blocks.h"; sourceTree = "<group>"; };
CC274114152F885C00E946AD /* NSInvocation+blocks.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "NSInvocation+blocks.m"; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -109,6 +111,8 @@
29B97315FDCFA39411CA2CEA /* Other Sources */ = {
isa = PBXGroup;
children = (
CC274113152F885C00E946AD /* NSInvocation+blocks.h */,
CC274114152F885C00E946AD /* NSInvocation+blocks.m */,
256AC3F00F4B6AF500CF3369 /* UAGithubEngine_Prefix.pch */,
29B97316FDCFA39411CA2CEA /* main.m */,
);
Expand Down
1 change: 1 addition & 0 deletions UAGithubEngine_Prefix.pch
Expand Up @@ -4,4 +4,5 @@

#ifdef __OBJC__
#import <Foundation/Foundation.h>
#import "NSInvocation+blocks.h"
#endif

0 comments on commit 0c7c29d

Please sign in to comment.