The Write.as desktop (GUI) app for macOS.
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

45 lignes
1.9 KiB

  1. //
  2. // Created by Matt Baer on 8/2/17.
  3. // Copyright (c) 2017 A Bunch Tell. All rights reserved.
  4. //
  5. import Foundation
  6. import Cocoa
  7. class Document: NSDocument {
  8. override init() {
  9. super.init()
  10. // Add your subclass-specific initialization here.
  11. }
  12. override class func autosavesInPlace() -> Bool {
  13. return false
  14. }
  15. override func makeWindowControllers() {
  16. // Returns the Storyboard that contains your Document window.
  17. let storyboard = NSStoryboard(name: "Main", bundle: nil)
  18. let windowController = storyboard.instantiateController(withIdentifier: "DocumentWindow") as! NSWindowController
  19. self.addWindowController(windowController)
  20. }
  21. override func data(ofType typeName: String) throws -> Data {
  22. // Insert code here to write your document to data of the specified type. If outError != nil, ensure that you create and set an appropriate error when returning nil.
  23. // You can also choose to override fileWrapperOfType:error:, writeToURL:ofType:error:, or writeToURL:ofType:forSaveOperation:originalContentsURL:error: instead.
  24. throw NSError(domain: NSOSStatusErrorDomain, code: unimpErr, userInfo: nil)
  25. }
  26. override func read(from data: Data, ofType typeName: String) throws {
  27. // Insert code here to read your document from the given data of the specified type. If outError != nil, ensure that you create and set an appropriate error when returning false.
  28. // You can also choose to override readFromFileWrapper:ofType:error: or readFromURL:ofType:error: instead.
  29. // If you override either of these, you should also override -isEntireFileLoaded to return false if the contents are lazily loaded.
  30. throw NSError(domain: NSOSStatusErrorDomain, code: unimpErr, userInfo: nil)
  31. }
  32. override var isDocumentEdited: Bool {
  33. // Never prompt user to save on exit
  34. return false
  35. }
  36. }