Skip to content

Instantly share code, notes, and snippets.

@jjthrash
Created November 13, 2013 15:15
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 jjthrash/7450703 to your computer and use it in GitHub Desktop.
Save jjthrash/7450703 to your computer and use it in GitHub Desktop.
+- (void)downloadDocumentAtURL:(NSURL*)url {
+ @autoreleasepool {
+ NSData *data = [NSData dataWithContentsOfURL:url];
+ NSString *filename = [[[NSUUID UUID] UUIDString] stringByAppendingPathExtension:@"pdf"];
+ NSString *fullPath = [NSTemporaryDirectory() stringByAppendingPathComponent:filename];
+
+ [data writeToFile:fullPath atomically:NO];
+
+ ReaderDocument *document = [ReaderDocument withDocumentFilePath:fullPath password:nil];
+ [self performSelectorOnMainThread:@selector(displayDocument:) withObject:document waitUntilDon
+ }
+}
+
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment