Last active
June 2, 2020 23:02
-
-
Save TyrfingMjolnir/6150c364795910c1764c7a08df78d8c0 to your computer and use it in GitHub Desktop.
My Microservice Apple System PreferencePane example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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