1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-07-17 13:29:02 +00:00
CLK/OSBindings/Mac/Clock Signal/Document Controller/DocumentController.swift

27 lines
763 B
Swift
Raw Normal View History

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