如何与AFNetworking 2,严格按顺序发送请求? [英] How send request with AFNetworking 2 in strict sequential order?

查看:289
本文介绍了如何与AFNetworking 2,严格按顺序发送请求?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在做同步到一个SQLite数据库镜像到一个服务器之一。

I'm doing the sync to mirror a sqlite DB to a server one.

我有一个主从表,其中的细节必须尽快发送到服务器。然而,可能是细节3细节2.之前,我需要模仿对文档所做的步骤和尊重操作的顺序到达。

I have a Master-Detail table, where the details must be send to the server ASAP. However, is possible that detail 3 arrive before detail 2. I need to mimic the steps made to the document and respect the order of the operations.

当一个记录保存在本地,我发一个通知,然后发布该数据。我怎么可以用AFNetworking保证严格的顺序?

When a record is saved locally, I send a notification and then post the data. How I can guarantee a strict sequential order using AFNetworking?

推荐答案

默认情况下,作业同时运行,没有保证的顺序。确保行动发挥的唯一方法是prevent从在给定时间运行的,由 operationQueue.maximumConcurrentOperations 属性设置为<$ C多个请求的操作$ C> 1 的(或者,如果你不使用管理,确保业务排队进入操作队列正是如此设定的属性)

By default, operations run concurrently, with no guarantee of order. The only way to ensure that actions play is to prevent more than one request operation from running at a given time, by setting the operationQueue.maximumConcurrentOperations property to 1 (or, if you're not using a manager, make sure to enqueue operations into an operation queue with the property set thusly).

这篇关于如何与AFNetworking 2,严格按顺序发送请求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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