开发者

how can i terminate api call in iphone

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 my app closed. Then i would open my app it will closed immediately.

can any one help me how can i terminate or kill the api call 开发者_Go百科while cancel it.


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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜