我如何终止 iphone 中的 api 调用 [英] how can i terminate api call in iphone

查看:24
本文介绍了我如何终止 iphone 中的 api 调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 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-over-http-on-the-iphone/ 它用于 JSON api 调用.如果您需要另一个 API,只需从通过 HTTP 获取 JSON"开始阅读,他们就会在那里设置一个 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆