How to pass a protocol as parameter, without using @objc?


(Bruno Macabeus) #1

Hello,

I wrote a gist to list all classes that subscribers a protocol:
https://gist.github.com/brunomacabeusbr/eea343bb9119b96eed3393e41dcda0c9
It work, but, I could not pass a protocol as parameter, then, I need wrote
one function each time I need to list class from different protocol.
I know how to pass a protocol using @obcj
<http://stackoverflow.com/a/27162499/3440266>, but I can't use @obcj,
because my protocols have property.


(Bruno Macabeus) #2

I found the solution. I need use a closure.
I updated the gist:
https://gist.github.com/brunomacabeusbr/eea343bb9119b96eed3393e41dcda0c9

···

2017-03-13 1:38 GMT-03:00 Bruno Macabeus <bruno.macabeus@gmail.com>:

Hello,

I wrote a gist to list all classes that subscribers a protocol:
https://gist.github.com/brunomacabeusbr/eea343bb9119b96eed3393e41dcda0c9
It work, but, I could not pass a protocol as parameter, then, I need wrote
one function each time I need to list class from different protocol.
I know how to pass a protocol using @obcj
<http://stackoverflow.com/a/27162499/3440266>, but I can't use @obcj,
because my protocols have property.


(Zhao Xin) #3

Great!

Zhaoxin

···

On Tue, Mar 14, 2017 at 2:15 PM, Bruno Macabeus via swift-users < swift-users@swift.org> wrote:

I found the solution. I need use a closure.
I updated the gist: https://gist.github.com/brunomacabeusbr/
eea343bb9119b96eed3393e41dcda0c9

2017-03-13 1:38 GMT-03:00 Bruno Macabeus <bruno.macabeus@gmail.com>:

Hello,

I wrote a gist to list all classes that subscribers a protocol:
https://gist.github.com/brunomacabeusbr/eea343bb9119b96eed3393e41dcda0c9
It work, but, I could not pass a protocol as parameter, then, I need
wrote one function each time I need to list class from different
protocol.
I know how to pass a protocol using @obcj
<http://stackoverflow.com/a/27162499/3440266>, but I can't use @obcj,
because my protocols have property.

_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users