asihttprequest crashes my app

前端 未结 4 492
自闭症患者
自闭症患者 2021-02-06 04:05

I have a navigation based app. Press a button on main view, then I push a new view to the navigation controller. All pretty basic stuff.

When the new view is loaded, I d

4条回答
  •  无人及你
    2021-02-06 04:37

    The error is that the delegate is still set.

    I have found 2 ways to fix this.

    The way I consider ugly is that you make a universal delegate that does all network traffic and is instantiated when the app is first run. I actually used the app delegate and listen to nsnotification center messages. It works like a charm, the app never crashes, but I think it is not optimal.

    The best way is to not set the delegate and not use "setDidFinishSelector", but instead use "setCompletionBlock:^". This will only work on devices running iOS 4.0 and up, which is more than 90-95% and growing. This is just an awesome way and will not crash the application.

提交回复
热议问题