Last active
August 29, 2015 14:02
-
-
Save henry0312/c36f70f2d8bcddb8546a to your computer and use it in GitHub Desktop.
TracMix written in Swift
This file contains 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 | |
class AppDelegate: NSObject, NSApplicationDelegate { | |
@IBOutlet var window: NSWindow | |
var track: Track! | |
@IBOutlet var textField : NSTextField | |
@IBOutlet var slider : NSSlider | |
@IBAction func mute(sender : AnyObject) { | |
//NSLog("received a mute: message") | |
track.volume = 0.0 | |
updateUserInterface() | |
} | |
@IBAction func takeFloatValueForVolumeFrom(sender : AnyObject) { | |
/* | |
var senderName: String | |
if sender is NSTextField { | |
senderName = "textField" | |
} else { | |
senderName = "slider" | |
} | |
NSLog("%@ sent takeFloatValueForVolumeFrom: with value %1.2f", senderName, sender.floatValue) | |
*/ | |
let newValue = sender.doubleValue | |
track.volume = newValue | |
updateUserInterface() | |
} | |
func updateUserInterface() { | |
let volume = track.volume | |
self.textField.doubleValue = volume | |
self.slider.doubleValue = volume | |
} | |
func applicationDidFinishLaunching(aNotification: NSNotification?) { | |
// Insert code here to initialize your application | |
track = Track() | |
updateUserInterface() | |
} | |
func applicationWillTerminate(aNotification: NSNotification?) { | |
// Insert code here to tear down your application | |
} | |
} |
This file contains 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 | |
class Track: NSObject { | |
var volume: Double | |
init() { | |
volume = 0.0 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See: