2012-02-15 24 views
0

讓我從一些代碼開始。當應用程序加載時,它調用下面:NSURLConnection中的擔保訂單

//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標誌,但是我需要經常檢查兩者是否都已收到。

回答