Skip to content

Instantly share code, notes, and snippets.

@xta
Forked from preble/RandomAppDelegate.swift
Last active August 29, 2015 14:08
Show Gist options
  • Save xta/08a343c05fef58df2b38 to your computer and use it in GitHub Desktop.
Save xta/08a343c05fef58df2b38 to your computer and use it in GitHub Desktop.
import Cocoa
class AppDelegate: NSObject, NSApplicationDelegate {
@IBOutlet var window: NSWindow
@IBOutlet var label: NSTextField
func applicationDidFinishLaunching(aNotification: NSNotification?) {
// Insert code here to initialize your application
}
func applicationWillTerminate(aNotification: NSNotification?) {
// Insert code here to tear down your application
}
@IBAction func seed(sender: AnyObject) {
srandom(CUnsignedInt(time(nil)));
label.stringValue = "Seed"
}
@IBAction func generate(sender: AnyObject) {
var generated = (random() % 100) + 1
label.stringValue = "Generated \(generated)"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment