Skip to content

Instantly share code, notes, and snippets.

@lprhodes
Created March 28, 2012 15:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lprhodes/2227668 to your computer and use it in GitHub Desktop.
Save lprhodes/2227668 to your computer and use it in GitHub Desktop.
//Return type 'id' must match previous return type 'void *' when block literal has unspecified explicit return type
//Return type 'id' must match previous return type 'void *' when block literal has unspecified explicit return type
typedef id (^AEURLResponseProcessor)(NSURLResponse *, id, NSError **);
+ (AEURLResponseProcessor)statusCode:(NSIndexSet *)acceptableCodes {
return [[^(NSURLResponse *response, id data, NSError **error){
if (![response isKindOfClass:[NSHTTPURLResponse class]]) {
if (error) {
*error = [AEExpect error:AEExpectResponseNotHTTPError
message:@"Response is not HTTP"];
}
return nil;
}
NSInteger statusCode = [(NSHTTPURLResponse *)response statusCode];
if (![acceptableCodes containsIndex:statusCode]) {
if (error) {
*error = [AEExpect error:AEExpectInvalidStatusCodeError
message:[NSString stringWithFormat:@"%@ (HTTP status %d)",
[NSHTTPURLResponse localizedStringForStatusCode:statusCode],
statusCode]];
}
return nil;
}
//Return type 'id' must match previous return type 'void *' when block literal has unspecified explicit return type
return data;
} copy] autorelease];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment