我想在其他應用程序中打開網絡文件。UIDocumentInteractionController和網絡文件
我的代碼:
NSURLRequest *req = [[NSURLRequest alloc] initWithURL:url];
[NSURLConnection sendAsynchronousRequest:req queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *resp, NSData *respData, NSError *error){
NSLog(@"resp data length: %i", respData.length);
NSArray *names = [objDict[@"name"] componentsSeparatedByString:@"."];
NSString *fileName = [@"downloaded." stringByAppendingString:names[names.count-1]];
NSString * path = [NSTemporaryDirectory() stringByAppendingPathComponent:fileName];
NSError *errorC = nil;
BOOL success = [respData writeToFile:path
options:NSDataWritingFileProtectionComplete
error:&errorC];
if (success) {
UIDocumentInteractionController *documentController = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:path]];
documentController.delegate = self;
[documentController presentOptionsMenuFromRect:CGRectZero inView:self.view animated:YES];
} else {
NSLog(@"fail: %@", errorC.description);
}
}];
它顯示面板,但在任何按鈕的點擊崩潰(不是 '取消' 只)。
我啓用了殭屍的對象,並將其寫入:
-[UIDocumentInteractionController URL]: message sent to deallocated instance