Creating a sample application using a protocol and a delegate
We will begin developing our actual application, Sales Record System for Departmental Store from Chapter 5, Creating, Listing, and Deleting Names of Customers. In this chapter, we will develop a small application that is meant for making you better understand the concept of protocol and delegate. The application that we are going to develop is a nice example of a class adopting a protocol. Here, we'll define a protocol called SecondViewControllerDelegate
, which has two methods: sum and multiply. These two methods are used to calculate the sum and product of two numbers. The class that will conform to this protocol is called demodelegateViewController.
It will implement the two protocol methods, sum and multiply. We will see how the delegate methods are invoked to calculate the sum and product of two numbers entered by the user:
1. Launch Xcode and select the New Project option from the File menu. The New Project Assistant window...