© Yanis Zafirópulos 2019
Yanis ZafirópulosSwift 4 Recipeshttps://doi.org/10.1007/978-1-4842-4182-0_13

13. More Advanced Topics

Yanis Zafirópulos1 
(1)
Granada, Spain
 

An application usually deals with things in a sequential way, more like a regular cooking recipe: 1, 2, 3, etc.

In this chapter, we’ll see how we can break this circle and interact with the system in a more natural way, either by executing commands in the terminal (pretty much as a normal user would) or launch asynchronous processes, which do what they have to in the background but still maintain contact with our main application.

13.1 Execute terminal command

Problem

I want to execute some terminal command and get the result.

Solution

import Foundation

First, we create our Process and Pipe ...

Get Swift 4 Recipes: Hundreds of Useful Hand-picked Code Snippets now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.