April 2015
Intermediate to advanced
556 pages
17h 47m
English
In MainWindowController.swift, update generatePassword(_:) to call generateRandomString() with a constant length.
import Cocoa
class MainWindowController: NSWindowController {
@IBOutlet weak var textField: NSTextField!
override func windowDidLoad() {
super.windowDidLoad()
// Implement this method to handle any initialization after your
// window controller's window has been loaded from its nib file
}
@IBAction func generatePassword(sender: AnyObject) {
// Get a random string of length 8
let length = 8
let password = generateRandomString(length)
// Tell the text field display the string
textField.stringValue = password
textField.stringValue = "button clicked"
}
}
Run the app, click the ...
Read now
Unlock full access