Re: Swift function overloading - invoking func with specific parameter (in place of Any parameter) on passing Any object

2019-10-28 Thread Andrew Thompson via Cocoa-dev
You may prefer this? In ViewController For each child in children child.displayTo(self) In each class such as Address Function displayTo(ViewController: target) target.display(self) This ought to work as the type of self will be precisely Address. You may be able to turn this into a pr

Re: Swift function overloading - invoking func with specific parameter (in place of Any parameter) on passing Any object

2019-10-27 Thread Andrew Thompson via Cocoa-dev
> Is there any other elegant way to achieve the desired behavior without > using `if-let + typecasting`? One way is to use classes instead on structs and define display as a method on those classes. I’m no Swift expert but I expect you may find value in making display() into a protocol. An