Created
February 15, 2010 15:41
-
-
Save ddribin/304741 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
NSOperationQueue * queue = [[[NSOperationQueue alloc] init] autorelease]; | |
NSURL * url = [NSURL URLWithString:@"http://www.example.com/"]; | |
id<DDFuture> futureData = [queue dd_submitCallableBlock:^id (NSError **error) { | |
NSData * data = [NSData dataWithContentsOfURL:url options:0 error:error]; | |
return data; | |
}]; | |
// This blocks for the result | |
NSError * error = nil; | |
NSData * data = [futureData result:&error]; | |
if (data != nil) { | |
NSString * string = [[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding] autorelease]; | |
NSLog(@"String:\n%@", string); | |
} else { | |
NSLog(@"Error: %@", error, [error userInfo]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment