how can i terminate api call in iphone

后端 未结 1 396
生来不讨喜
生来不讨喜 2021-01-26 16:36

I am new to iPhone. i have faced a new problem. I have an api interaction in my app. That api take long time for loading. when i terminate my app manually,while loading that api

相关标签:
1条回答
  • 2021-01-26 17:04

    I suppose you mean a web API call, like google's geoservices. To do this, you will need to make the call using a NSURLConnection. This way, you can cancel a call anytime using [connection cancel].

    Try this tutorial: http://mobileorchard.com/tutorial-json-over-http-on-the-iphone/ It's meant for a JSON api call. If you need another API, just start reading from 'fetching JSON over HTTP', there they set up a NSURLConnection. If you retain this connection until it's done, you will be able to make the [connection cancel] call at anytime.

    Using the UIApplicationDelegate, you can detect the app entering the background.

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