2

I Convert my Objective C + Swift 2.x code to Swift 3 in Xcode 8. After converting the code i am getting these new warning that i don't know if it's safe ti ignore/how to resolve it.

My Swift 3 code :

func getUserNotificationFromServer(_ completionQueue:DispatchQueue = DispatchQueue.main,callback: @escaping (_ succeeded: Bool, _ response: AnyObject?) -> Void)  {

Objective C code that calls this function

 [wsManager getUserFavouritesFromServer:dispatch_get_main_queue() callback:^(BOOL succeeded, id  _Nullable response) {

Warning that i am receiving

Incompatible pointer types sending 'dispatch_queue_t _Nonnull' (aka 'NSObject *') to parameter of type 'OS_dispatch_queue * _Nonnull'

Any thoughts ?

Mihir Mehta
  • 13,743
  • 3
  • 64
  • 88
  • check this post, here is described perfectly: [link](http://stackoverflow.com/questions/37805885/how-to-create-dispatch-queue-in-swift-3) – Vadim Kozak Dec 08 '16 at 11:21
  • That post talks about Swift code, this warning comes when i call method written in Swift 3 from my Objective C class – Mihir Mehta Dec 08 '16 at 11:25

1 Answers1

1

I don't understand why, but the DispatchQueue is exposed as OS_dispatch_queue * in the generated {ProjectModuleName}-Swift.h .

(Better send a bug report to Apple.)

As far as I tested, just casting as suggested in the message suppresses the warning, and the code works as expected:

[wsManager getUserNotificationFromServer:(OS_dispatch_queue * _Nonnull)dispatch_get_main_queue()
                                callback:^(BOOL succeeded, id  _Nullable response) {
OOPer
  • 47,149
  • 6
  • 107
  • 142