Created
September 5, 2016 11:02
-
-
Save Darmaal/241c87d9efda8df1b708760a04793022 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
//this file is to get the user input --> processor | |
//return a string --> which is the user input --> we use foundational classes provided by Apple | |
func getUserInput() -> String { | |
let standardInput = NSFileHandle.fileHandleWithStandardError() | |
//NSFileHandle.fileHandleWithStandardInput() | |
//another class provided by Apple -> allows us to access NextConsole | |
//adding line breaks automatically | |
var input = NSString(data: standardInput.availableData, encoding: NSUTF8StringEncoding) | |
input = input!.stringByTrimmingCharactersInSet(NSCharacterSet.newlineCharacterSet()) | |
//as -> | |
return input as! String | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment