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

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
<How passing a protocol as parameter in Swift - Stack Overflow, but I can't use @obcj,
because my protocols have property.

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
<How passing a protocol as parameter in Swift - Stack Overflow, but I can't use @obcj,
because my protocols have property.

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
<How passing a protocol as parameter in Swift - Stack Overflow, 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

Hey Bruno, I'm trying to solve the same problem. Your gist leads to a 404 right now. Any chance you've still got it available?

Wow, it's an ancient post.

I updated my GitHub username. Here's the new link: List all classes that subscribe a protocol ยท GitHub


Relevant xkcd
image

1 Like

Hey,

Wow, it's a very old gist.
I updated my GitHub username. Here's the new link: https://gist.github.com/macabeus/eea343bb9119b96eed3393e41dcda0c9

Doesn't that only work on platforms with the objc runtime?