sendTwitterRequest:completion: does not run completion block on main queue

ios

#1

The docs state “Completion block to be called on response. Called on main queue.” See Screenshots, first one is breakpoint hit when my function is initially called (main thread). Second one is breakpoint hit in the completion block which is not on the main thread. Is this a bug in TwitterKit?

In the completion block I launch another request and naturally see the debug message:

TwitterKit must be used only from the main thread. Use from background threads will lead to unexpected behavior and crashes.

Note that although my function is recursive this 2nd breakpoint is before any recursion has occurred. This message did not show with the previous version of TwitterKit (1.9.0).


#2

This fixed the debug messages:

        client.sendTwitterRequest(request) { (response, data, connectionError) -> Void in
            // Even though the docs state that the completion block is called on the main thread, this was not the case.
            // So force it to be dispatched on the main thread. 
            dispatch_async(dispatch_get_main_queue(),{
               // Recursive call that ends up calling client.sendTwitterRequest().
            })
        }

#3