NSURLConnection-Blocks icon indicating copy to clipboard operation
NSURLConnection-Blocks copied to clipboard

Added typedef's for the blocks

Open dglancy opened this issue 13 years ago • 0 comments

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]; }

dglancy avatar Dec 29 '11 20:12 dglancy