问题标签 [afhttpclient]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
101 浏览

afnetworking - Why is success block being called with incorrect path?

I accidentally mistyped the post path and noticed that although it's being wrong, the success block is called:

Of course the data are not being sent to server and the transaction is not processed, but I want to know why it's not the failure block which is supposed to be called in case the path is wrong? Thanx.

0 投票
2 回答
849 浏览

objective-c - AFNetworking 获取 XML 解析错误的数据

这是我的 AFHTTPClient 单例:

和同一类中的方法(AFHTTPClient):

当我调用此函数从 RSS 获取 XML 时,我收到此错误:

问题:

  1. 实施单例的整个概念是否良好,我需要任何更改吗?

  2. 如果整个概念是错误的,有什么建议吗?

  3. 为什么我会收到此错误?

谢谢。

0 投票
1 回答
119 浏览

grand-central-dispatch - 告诉 dispatch_main_queue 从主队列处理它的所有块?

我正在使用 AFHTTPClient 进行测试以测试后端响应。

这样做的问题是它等待所有操作完成但它不执行成功块,因为它被调度到 dispatch_get_main_queue()。有没有办法告诉 dispatch_get_main_queue() 从主队列完成它的块?

0 投票
1 回答
1593 浏览

ios - AFHTTPClient + enqueueBatchOfHTTPRequestOperations:处理取消和错误

我的应用程序需要从网络上获取一些图像,但我希望用户能够取消此下载(如果它没有连接,或者它太慢,或者 w/e)。无论如何,应用程序界面都不应该被“冻结”。所以我使用AFHTTPClientwithenqueueBatchOfHTTPRequestOperations:progressBlock:completionBlock:方法下载:

如果按下“取消下载”按钮:

我的问题是:

我不知道应该在哪里检查操作错误和取消(在这种情况下,我想取消整个下载并删除 UI 阻止对话框)。在我看来,最好的地方是completionBlock:enqueueBatchOfHTTPRequestOperations:因为它保证所有操作都已完成,并且我可以访问NSArray *operations,所以我可以检查它是错误还是取消,就像我在 中所做的那样failure:。但是我发现这个块在这种情况下甚至没有执行(可能是因为 isCancelled、isFinished、isExecuting 属性机制)。

那么如果是错误或用户按下“取消下载”按钮,我应该如何删除 UI 阻止对话框并取消下载?

更新

不知道为什么,但是在这个例子中 AFNetworking取消检查中的 Canceling batch request 是在 中completionBlock:,正是我要放它的地方!但在我的情况下,如果任何操作被取消,这个块就不会执行!也许我在配置我的 AFHTTPClient 时遗漏了一些东西?

0 投票
1 回答
362 浏览

java - AFHTTPRequest 结果为空(即使我可以在浏览器中看到 JSON)

我正在使用 GET 请求来获取 JSON 数据。

调用如下所示:

当我在浏览器上查询时,我得到了这个:

此响应由我在服务器上的方法发送(在 java 中):

不知道为什么 xcode 不处理响应...当我查看调试器中的值时,它显示 responseObject = x0000000 (null)

在此处输入图像描述

0 投票
1 回答
157 浏览

iphone - AFHTTPClient 不发送完整数据

我正在使用以下代码发送一个 wav 文件,但是,该过程在

所以?代码有问题吗?还是我错过了什么?

0 投票
1 回答
1560 浏览

ios - MBProgressHud、AFnetworking 和刷新数据

我正在使用 AFnetworking 调用服务器。下载时,我使用 MBProgressHUD 来显示正在下载数据。到目前为止,一切都很好。我的问题是当我按下主页按钮然后重新启动应用程序时。我希望页面自动刷新并让 MBProgressHUD 向用户显示正在下载的内容。这是我做不到的。我可以下载数据,但我无法让 HUD 部分工作。

首先,在 viewDidLoad 方法中添加:

现在在方法applicationDidBecomeActiveNotificationAction中,我调用[self downloadWebsites]

在方法downloadWebsites中完成了大部分工作:这里是:

为什么这不起作用?我可以得到数据。但我无法让 progressHud 显示。我该如何解决?

0 投票
1 回答
3601 浏览

ios - AFNetworking - Upload video along with other parameters

I want to upload video to web service along with some other parameters. I want to upload userID, videoID and video to web service. While uploading, all the parameters other than video is being sent to web service. I've checked at web service end, and the video is not coming with the request. I am using the following code.

Could anyone let me know whether I am doing it correct? If not, could anyone please tell me how to upload video to web service along with other parameters?

Thanks Everyone!

0 投票
1 回答
438 浏览

ios - 使用 AFIncrementalStore 和 AFRestClient 进行分页

任何人都可以展示一些关于如何使用 AFPaginator 进行分页的示例。我正在使用 AFRestClient,我需要在我对实体的请求中关联 pagerId、offset 和 count 参数。

在我看来,通过使用 AFPaginator 关联这些参数应该是直截了当的。我搜索了一些示例,但找不到任何示例。

0 投票
0 回答
896 浏览

objective-c - AFHTTPClient 子类中的 setDownloadProgressBlock

我创建了AFHTTPClient.

它有效,但progress块只返回最终值(1.0)。我应该改变什么来获取所有计算值setDownloadProgressBlock