Created
November 3, 2014 10:10
-
-
Save hekt/a688c822693ec2682e7f to your computer and use it in GitHub Desktop.
LetterCountChallenge アプリケーションの 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! | |
@IBOutlet weak var textLabel: NSTextField! | |
@IBAction func countChars(sender: AnyObject) { | |
let str = textField.stringValue | |
let count = countElements(str) | |
textLabel.stringValue = "'\(str)' has \(count) characters." | |
} | |
func applicationDidFinishLaunching(aNotification: NSNotification) { | |
// Insert code here to initialize your application | |
} | |
func applicationWillTerminate(aNotification: NSNotification) { | |
// Insert code here to tear down your application | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment