Skip to content

Instantly share code, notes, and snippets.

@henry0312
Last active August 29, 2015 14:02
Show Gist options
  • Select an option

  • Save henry0312/c36f70f2d8bcddb8546a to your computer and use it in GitHub Desktop.

Select an option

Save henry0312/c36f70f2d8bcddb8546a to your computer and use it in GitHub Desktop.

Revisions

  1. henry0312 revised this gist Jun 21, 2014. 2 changed files with 0 additions and 16 deletions.
    8 changes: 0 additions & 8 deletions AppDelegate.swift
    Original file line number Diff line number Diff line change
    @@ -1,11 +1,3 @@
    //
    // AppDelegate.swift
    // TrackMix
    //
    // Created by Tsukasa OMOTO on 2014/06/18.
    // Copyright (c) 2014年 Tsukasa OMOTO. All rights reserved.
    //

    import Cocoa

    class AppDelegate: NSObject, NSApplicationDelegate {
    8 changes: 0 additions & 8 deletions Track.swift
    Original file line number Diff line number Diff line change
    @@ -1,11 +1,3 @@
    //
    // Track.swift
    // TrackMix
    //
    // Created by Tsukasa OMOTO on 2014/06/18.
    // Copyright (c) 2014年 Tsukasa OMOTO. All rights reserved.
    //

    import Cocoa

    class Track: NSObject {
  2. henry0312 created this gist Jun 21, 2014.
    58 changes: 58 additions & 0 deletions AppDelegate.swift
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,58 @@
    //
    // AppDelegate.swift
    // TrackMix
    //
    // Created by Tsukasa OMOTO on 2014/06/18.
    // Copyright (c) 2014年 Tsukasa OMOTO. All rights reserved.
    //

    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
    }


    }
    17 changes: 17 additions & 0 deletions Track.swift
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    //
    // Track.swift
    // TrackMix
    //
    // Created by Tsukasa OMOTO on 2014/06/18.
    // Copyright (c) 2014年 Tsukasa OMOTO. All rights reserved.
    //

    import Cocoa

    class Track: NSObject {
    var volume: Double

    init() {
    volume = 0.0
    }
    }