- Create a new Xcode project with the Single View Application template and name it NetworkingDemo.
- Let's add a button at the center of the screen so that when a user clicks on it, we will trigger a server connection to fetch some data.
- Open Main.storyboard and add a button at the center, with the title Connect:
- Link an IBOutlet and IBAction to the button, as follows:
@IBOutlet weak var connectButton: UIButton! @IBAction func didClickOnConnectButton(_ sender: Any) { }
- Now, create a new Swift file for a new class called ContactsManager. This class will be responsible for fetching contacts information from a server.