Fix compile errors; add file-exists test and logging.

This commit is contained in:
Seamus Campbell 2015-03-05 17:58:39 -08:00
parent 755e722cc8
commit 56b0c4ddd6

View File

@ -42,22 +42,29 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
NSArray *dotParts = [path componentsSeparatedByString:@"."];
NSString *fileExt = [dotParts lastObject];
NSString *uti = (__bridge NSString *)UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, (__bridge CFStringRef)fileExt, NULL);
uti = (__bridge NSString *)UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, (__bridge CFStringRef)fileExt, NULL);
}
dispatch_async(dispatch_get_main_queue(), ^{
//NSLog(@"path %@, uti:%@", path, uti);
NSURL *fileURL = [NSURL fileURLWithPath:path];
localFile = fileURL.path;
NSLog(@"looking for file at %@", fileURL);
NSFileManager *fm = [NSFileManager defaultManager];
if(![fm fileExistsAtPath:localFile]) {
NSLog(@"couldn't find file!");
} else {
NSLog(@"file located, handing off to UIDocumentInteractionController");
}
self.controller = [UIDocumentInteractionController interactionControllerWithURL:fileURL];
self.controller.delegate = self;
self.controller.UTI = uti;
CGRect rect = CGRectMake(0, 0, 1000.0f, 150.0f);
CDVPluginResult* pluginResult = nil;
BOOL wasOpened = [docController presentOptionsMenuFromRect:rect inView:cont.view animated:NO];
BOOL wasOpened = [self.controller presentOptionsMenuFromRect:rect inView:cont.view animated:NO];
if(wasOpened) {
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString: @""];