Just in case you're as new to XCode as me and want to try the snippets posted in Leandro's answerLeandro's answer:
- File->New->Project
- choose Command Line Tool as a project preset and name the project "cliinput"
- right-click in the project navigator (the blue panel on the left) and choose "New File..."
- In the drop down dialog name the file "UserInput". Uncheck the box "Also create a header file". Once you click "Next" you will be asked if XCode should create the Bridging-Header.h file for you. Choose "Yes".
- Copy & paste the code from Leandro's answer above. Once you click on the play button it should compile and run in the terminal, which in xcode is built-in in the bottom panel. If you enter a number in the terminal, a number will be returned.