Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using custom FileSpecificationProvider #32

Open
ottz972 opened this issue Jun 16, 2017 · 0 comments
Open

Using custom FileSpecificationProvider #32

ottz972 opened this issue Jun 16, 2017 · 0 comments

Comments

@ottz972
Copy link

ottz972 commented Jun 16, 2017

I'm attempting to utilize a custom FileSpecificationProvider to display .txt files in a certain format, however the FileExplorerViewController brings up the UknownFileTypeViewController instead.

class FileViewController: UIViewController {
    override func viewDidLoad() {
        super.viewDidLoad()
        
        let fileExplorer = FileExplorerViewController()
        fileExplorer.delegate = self as? FileExplorerViewControllerDelegate
        fileExplorer.fileSpecificationProviders = [TXTSpecificationProvider.self]
        
        self.present(fileExplorer, animated: true, completion: nil)
    }
}

public class TXTSpecificationProvider: FileSpecificationProvider {
    public class var extensions: [String] {
        return ["txt"]
    }
    
    public static func thumbnail(forItemAt url: URL, with size: CGSize) -> UIImage? {
        return nil
    }
    
    public class func viewControllerForItem(at url: URL, data: Data?, attributes: FileAttributes) -> UIViewController {
        return ThisPlacePreviewViewController(fileName: url.absoluteString)
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant