Created
November 3, 2014 05:08
-
-
Save hekt/9523219adaa40b09cfcc to your computer and use it in GitHub Desktop.
SpeakLine アプリケーションの Swift 版 (『MAC OS X COCOA プログラミング』第5章)
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 | |
@NSApplicationMain | |
class AppDelegate: NSObject, NSApplicationDelegate { | |
@IBOutlet weak var window: NSWindow! | |
@IBOutlet weak var textField: NSTextField! | |
let speechSynth = NSSpeechSynthesizer(voice: nil) | |
@IBAction func stopIt(sender: AnyObject) { | |
NSLog("stopping") | |
speechSynth.stopSpeaking() | |
} | |
@IBAction func sayIt(sender: AnyObject) { | |
let string = textField.stringValue | |
if countElements(string) == 0 { | |
NSLog("String from %@ is of zero-length", textField) | |
return | |
} | |
speechSynth.startSpeakingString(string) | |
NSLog("Have started to say: %@", string) | |
} | |
func applicationDidFinishLaunching(aNotification: NSNotification) { | |
NSLog("init") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment