Monotouch + UIWebView = Random Crashes

前端 未结 1 1530
半阙折子戏
半阙折子戏 2021-01-06 05:14

I\'m using the latest stable releases of Mono/Monotouch/MonoDevelop on a iOS 5.0 iPhone and iPad. I have a UIWebView that in the emulator never crashes however randomly on

相关标签:
1条回答
  • 2021-01-06 05:44

    I would need to see the crash details and a but more of source code to be 100% certain but I do believe it's caused because your NSUrlRequest instance is declared as a local variable. Promote this variable into a field of your type should solve this.

    The instance could still be required once the method is completed it's execution. However at that time it's not referenced anymore and the garbage collector can collect it anytime. If collected then you'll likely get a crash like you mentioned.

    The fact it does not occur on the simulator is likely caused because it's faster (than the device) and the code can complete before the GC collect that instance. IOW it could crash it's just a timing thing that makes it work most of the time on the simulator and almost never on devices.

    0 讨论(0)
提交回复
热议问题