我怎样才能终止iphone API调用 [英] how can i terminate api call in iphone
问题描述
我是新来的iPhone。我都面临着一个新的问题。我在我的应用程序的API互动。该API需要很长时间加载。当我手动终止我的应用程序,加载该API我的应用程序关闭。然后,我会打开我的应用程序将立即关闭。
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.
任何一个可以帮助我,我怎么能终止或杀死API调用,同时取消。
can any one help me how can i terminate or kill the api call while cancel it.
推荐答案
我想你的意思是一个Web API调用,像谷歌的地理服务。要做到这一点,你将需要使用NSURLConnection的呼叫。通过这种方式,您可以使用取消呼叫随时[连接取消。
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].
试试这个教程: http://mobileorchard.com/tutorial -json环比HTTP上最iphone / 它意味着一个JSON API调用。如果您需要另一个API,刚开始从获取JSON通过HTTP'读书,他们在那里建立了一个NSURLConnection的。如果你直到把它完成保持这种连接,您将能够使随时[连接取消]客服。
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.
使用UIApplicationDelegate,可以检测应用程序进入后台。
Using the UIApplicationDelegate, you can detect the app entering the background.
这篇关于我怎样才能终止iphone API调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!