NSURLConnection-Blocks
NSURLConnection-Blocks copied to clipboard
Added typedef's for the blocks
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]; }