Search code examples
ios5twittertwrequest

iOS 5 Twitter performRequestWithHandler does not work on device


I've converted from using MGTwitterEngine to the new iOS 5.0 twitter API. My app works like a champ when running in the simulator. However, when I run it on the iPad (a device) performRequestWithHandler always ends up with a request timeout. I have allowed my app access to my Twitter account, and the official iPad Twitter client (which is also using the new iOS 5.0 twitter api) works fine.

I am at a loss why it will not work on the device when it works great in the simulator.

My iPad is running software version 5.0.1 (9A405)


Solution

  • Turns out that my issue was related to making the Twitter calls within a NSOperation. I noticed on the device if I brought up other UIViews (or generally manipulated the UI) it would complete the Twitter execution. If I did not touch the UI and wait, it would timeout. So it seems the Twitter operations on a non-main thread behaved differently between the simulator and on an actual device.

    Pulling all of my TWRequest calls into the main thread solved the issue.

    I did not experience this problem with my prior implementation using MGTwitterEngine.

    Is anyone aware of different thread behavior of the iOS 5.0 Twitter framework?