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

2019-10-27 Thread Devarshi Kulshreshtha via Cocoa-dev
So the other thing which came to my mind was similar to what you have suggested: a. Declare Displayable protocol with func display() b. Let each Model implement this protocol c. Within forEach on children I can just bind and typecast to the protocol and invoke display method on it However this lo

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

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

2019-10-27 Thread Devarshi Kulshreshtha via Cocoa-dev
I have 3 structs: struct Address: Codable { var addressLine1: String } struct Person: Codable { var name: String } struct Order: Codable { var person: Person? var address: Address? } In my ViewController class I am using Mirror to access eac