4

Is there a way to open a file with QLPreviewController or UIDocumentInteractionController, knowing its UTI, but without a file extension in the NSURL? Thanks for your help!

Martin
  • 2,290
  • 1
  • 23
  • 28

2 Answers2

10

I've just found another way to deal with it. Implement an item with the following properties:

@interface QuickLookPreviewItem : NSObject <QLPreviewItem>
@property (nonatomic, strong) NSURL *url;
@property (nonatomic, strong) NSString *title;
@property (nonatomic, strong) NSString *uti;
@end

@implementation QuickLookPreviewItem
- (NSString *)previewItemTitle { return self.title; }
- (NSURL *)previewItemURL { return self.url; }
- (NSString *)previewItemContentType { return self.uti; }
@end

Though it's not clear that it works that way in the documentation.

Martin
  • 2,290
  • 1
  • 23
  • 28
  • it's work like a charm, but it's undocumented, so its supposed to be a private API... probably because UTI standard it's just an Apple thing, it's not a standard: https://developer.apple.com/library/mac/documentation/Miscellaneous/Reference/UTIRef/Articles/System-DeclaredUniformTypeIdentifiers.html – Cesar Jan 08 '14 at 12:16
  • This also works for Swift 3. Since it's private API, would it pass an app store review? – ThottChief Oct 11 '16 at 21:42
0

add the file extension to the path while quick-looking it :) before push => add extension after pop => remove it again

Daij-Djan
  • 49,552
  • 17
  • 113
  • 135