rabbitmq / rabbitmq-objc-client

RabbitMQ client for Objective-C and Swift
https://rabbitmq.com
Other
241 stars 84 forks source link

Ambiguous subscribe method (swift bridging) #99

Closed joshrl closed 5 years ago

joshrl commented 7 years ago

The following code produces a compile error:

queue.subscribe {
    message in
}
(File Path Truncated).swift:34:9: error: ambiguous use of 'subscribe'
        queue.subscribe {
        ^
RMQClient.RMQQueue:53:15: note: found this candidate
    open func subscribe(_ handler: RMQClient.RMQConsumerDeliveryHandler!) -> RMQConsumer!
              ^
RMQClient.RMQQueue:58:15: note: found this candidate
    open func subscribe(_ options: RMQBasicConsumeOptions = [], handler: RMQClient.RMQConsumerDeliveryHandler!) -> RMQConsumer!

Short term solution is to use:

queue.subscribe([]) {
    message in
}

Tested with Xcode 8, swift 3, iOS 10.0 Base SDK, iOS 8.2 Deployment target

michaelklishin commented 7 years ago

Swift 3 support is a work-in-progress.

joshrl commented 7 years ago

@michaelklishin np -- just wanted to raise. Is there anything else documented that will not work with swift 3 / iOS 10?

michaelklishin commented 7 years ago

No idea. We have just ported our test suite to Swift 3 an hour or so ago.

camelpunch commented 7 years ago

@joshrl: You now need to include parens to disambiguate. See this updated test as an example:

https://github.com/rabbitmq/rabbitmq-objc-client/commit/0f5516383faa44c6bd64878bf043a3fb9380bc42#diff-6c21ccc4b47a3bcfa81308002c1dfa3bR87

camelpunch commented 7 years ago

Note that your workaround triggers a different method that will not include the .noAck option by default. We'll need to revisit this area once Travis calms down and OSX support is in.

michaelklishin commented 5 years ago

I think this has been addressed in master simply because the API has changed (slightly) in order to make things nicer for Swift users.