Skip to content

Instantly share code, notes, and snippets.

@TyrfingMjolnir
Last active June 2, 2020 23:02
Show Gist options
  • Save TyrfingMjolnir/6150c364795910c1764c7a08df78d8c0 to your computer and use it in GitHub Desktop.
Save TyrfingMjolnir/6150c364795910c1764c7a08df78d8c0 to your computer and use it in GitHub Desktop.
My Microservice Apple System PreferencePane example
import Cocoa
import PreferencePanes
class MyMicroservices: NSPreferencePane {
@IBAction func myButton(_ sender: Any ) {
FileManager.default.createFile( atPath: NSString( "/tmp/MyMicroservices.txt" ).expandingTildeInPath,
contents: "\( Date() ) Amended".data( using: .utf8 ),
attributes: nil )
// echo "Amended" >> /tmp/MyMicroservices.txt
}
override func mainViewDidLoad() {
super.mainViewDidLoad()
FileManager.default.createFile( atPath: NSString( "/tmp/MyMicroservices.txt" ).expandingTildeInPath,
contents: "\( Date() ) Created".data( using: .utf8 ),
attributes: nil )
// echo "Created" > /tmp/MyMicroservices.txt
}
override var shouldUnselect: NSPreferencePaneUnselectReply {
DispatchQueue.main.asyncAfter( deadline: .now() + 4 ) {
self.reply( toShouldUnselect: true )
}
return .unselectLater
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment