Skip to content

Added typedef's for the blocks#1

Open
dglancy wants to merge 1 commit intorickerbh:masterfrom
dglancy:master
Open

Added typedef's for the blocks#1
dglancy wants to merge 1 commit intorickerbh:masterfrom
dglancy:master

Conversation

@dglancy
Copy link

@dglancy dglancy commented Dec 29, 2011

For folks who don't like to do inline blocks, these typedef's are helpful to define the success and failure blocks upfront.

Example of how I would use them:

  • (void)requestSession {

    RequestSuccessBlock successBlock = ^(NSData *data, NSURLResponse *response) {
    DLog(@"success");
    };

    RequestFailureBlock failureBlock = ^(NSData *data, NSError *error) {
    DLog(@"failure");
    };

    NSString *url = [NSString stringWithFormat:SOME_URL , [self email], [self password]];
    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL: [NSURL URLWithString: url] cachePolicy: NSURLRequestUseProtocolCachePolicy timeoutInterval: 60.0];
    [NSURLConnection asyncRequest:request success:successBlock failure:failureBlock];
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant