gpt4 book ai didi

objective-c - NSURLConnection 中的保证顺序

转载 作者:行者123 更新时间:2023-11-29 04:48:14 24 4
gpt4 key购买 nike

让我从一些代码开始。当应用程序加载时,它会调用以下内容:

//Creates custom URL for request, loads the request, and upon completion (as per the delegate response, it runs the selector)

//List of programs
URLCreator * getListURL = [[URLCreator alloc] initStandard:@"getList"];
WebManager *getListWM = [[WebManager alloc]init];
[getListWM load:[getListURL finalURL] withSelector:@selector(createProgramList)];

//Sorting order for program list
URLCreator * getSortURL = [[URLCreator alloc] initStandard:@"getSort"];
WebManager *getSortWM = [[WebManager alloc]init];
[getSortWM load:[getSortURL finalURL] withSelector:@selector(sortThroughPrograms)];

到目前为止,这段代码运行良好,除了一件事 - 我的响应不按顺序排列。这是可以预料的,因为程序列表比排序顺序大得多。基本上,需要发生的是我需要保证我有程序列表和排序顺序,然后才能执行任何类型的排序算法。

在不通过同步请求锁定程序的情况下,保证在执行排序算法之前同时拥有两者的最佳方法是什么?当然,我可以设置 BOOL 标志,但我需要不断检查两者何时已收到。

最佳答案

关于objective-c - NSURLConnection 中的保证顺序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9301877/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com