Search code examples
swiftmacosactioncfbundledocumenttypes

Handling two document type


I'm developping a mac application that allow to transcribe/subtitles video. I must deal with two kind of document type:

  • SRT file (read/write)
  • Video file (read only)

For now SRT is the only document type of my application. I open video with an Open a video... menu item (under File), I connected to the openVideo action of the First responder.

Here is the code of my VideoControlerView called when pressing Open a video... :

@IBAction func openVideo(sender: AnyObject) {
    let dlg = NSOpenPanel()
    dlg.runModal()
    if let url = dlg.URL {
        self.playerView.player = AVPlayer(URL: url)
    }
}

I'm sure it is possible to benefit from the multi document type handling of document based application but I can't figure how. Any idea?


Solution

  • After questionning Apple Developer support about it, DocumentType is only designed for the editing document (SRT in my case).

    The way I handle my asset (video file) is the proper way to go!