1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-07-16 22:28:57 +00:00
CLK/OSBindings/Mac/Clock Signal/Document Controller/DocumentController.swift

26 lines
715 B
Swift

//
// DocumentController.swift
// Clock Signal
//
// Created by Thomas Harte on 18/06/2016.
// Copyright © 2016 Thomas Harte. All rights reserved.
//
import Cocoa
class DocumentController: NSDocumentController {
override func makeDocumentWithContentsOfURL(url: NSURL, ofType typeName: String) throws -> NSDocument {
if let analyser = CSStaticAnalyser(fileAtURL: url) {
if let documentClass = analyser.documentClass as? NSDocument.Type {
let document = documentClass.init()
if let machineDocument = document as? MachineDocument {
machineDocument.configureAs(analyser)
return machineDocument
}
}
}
return try! super.makeDocumentWithContentsOfURL(url, ofType: typeName)
}
}