The correct way to do this is to use readLine
, from the Swift Standard Library.
Example:
let response = readLine()
Will give you an Optional value containing the entered text.
More Related Contents:
- Convert String to URL (Why is resulting variable nil)
- Saving WebView to PDF returns blank image?
- How to listen to global hotkeys with Swift in a macOS app?
- Getting a “This application is modifying the autolayout engine from a background thread” error?
- NSObject subclass in Swift: hash vs hashValue, isEqual vs ==
- Do Swift-based applications work on OS X 10.9/iOS 7 and lower?
- How to get Ip address in swift
- Iterate through files in a folder and its subfolders using Swift’s FileManager
- Keep window always on top?
- Saving CGImageRef to a png file?
- USB Connection Delegate on Swift
- Load local web files & resources in WKWebView
- Selecting global or object print function
- In SwiftUI, How do I increase the height of a button?
- SwiftUI Drag and Drop files
- How do I access program arguments in Swift?
- OSX application without storyboard or xib files using Swift
- How to access NSWindow from @main App using only SwiftUI?
- Swift 5.4 hex to NSColor
- Swift5 MacOS ImageResize memory issue
- Why is the return value of String.addingPercentEncoding() optional?
- How to get user home directory path (Users/”user name”) without knowing the username in Swift3
- Is there a correct way to determine that an NSNumber is derived from a Bool using Swift?
- Cocoa/ Objective-C Shell Command Line Execution
- SwiftUI 2: the way to open view in new window
- How do you use CGEventTapCreate in Swift?
- Adjust screen brightness in Mac OS X app
- Programmatically Screenshot | Swift 3, macOS
- What is an optional value in Swift?
- How can I get text to wrap in a UILabel (via UIViewRepresentable) without having a fixed width?