Hello:
I want to capture the input value in a text field into a variable. Here is my code:
var window: NSWindow?
func checkGroupName() {
let alert = NSAlert()
alert.messageText = "Please enter your group name"
alert.addButton(withTitle: "Save")
alert.addButton(withTitle: "Cancel")
let inputTextField = NSTextField(frame: NSRect(x: 0, y: 0, width: 300, height: 24))
inputTextField.placeholderString = ("Enter your group name")
alert.accessoryView = inputTextField
alert.runModal()
let object = NSTextField()
let value = object.stringValue
print("The value of Group Name is \(value)")
}
What should I add to the above code to get the value entered in a variable i can use later in the code? "value" above is empty.