In my application, I want to create a dialog box with one text field, and a button, through which I can prompt user and get back user entered value.
How do I do this
IN OS X 10.10:
NSAlert *alert = [[NSAlert alloc] init];
[alert setMessageText:@"Permission denied, sudo password?"];
[alert addButtonWithTitle:@"Ok"];
[alert addButtonWithTitle:@"Cancel"];
NSTextField *input = [[NSTextField alloc] initWithFrame:NSMakeRect(0, 0, 200, 24)];
[input setStringValue:@""];
[alert setAccessoryView:input];
NSInteger button = [alert runModal];
if (button == NSAlertFirstButtonReturn) {
password = [input stringValue];
} else if (button == NSAlertSecondButtonReturn) {
}