coolly coolly - 2 years ago 100
Swift Question

How can I allow my function to accepts two different objects in swift?

I have a function which takes one argument. I wanted my function to accept two object types. How can I do it? Here is the example below:

func accept(user: Customer) {

It should accept Customer and Employee object reference.


Please help me in this case.

Answer Source

You can create a super class called People of Cutomer and Employee.

Then set user as type of People:

func accept(user: People) {
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download