0
這是我的要求。 Web服務需要在輔助線程上調用以將人員數據作爲字典數組發送。 ({名稱:PERSON1, 地址:印度 照片:一個路徑1 }; {名稱:PERSON2, 地址:印度 照片:一個路徑2 } ) 在本作的照片,我們還有其他的Web服務,我們上傳圖片並獲得回覆路徑。其他線程內的輔助線程
我做了什麼。 寫了一個函數並在輔助線程上調用它並啓動了一個活動指示器。 函數for循環正在製作這個字典。它工作正常。 但是當我同步上傳圖像時,活動指示燈停止。如果我異步執行操作,那麼當我獲得路徑響應時,我的main for循環就消失了,我沒有字典對象來添加路徑。
-(BOOL)callSynchWebService
{
__block BOOL validateFlag=NO;
MBProgressHUD * progressHud = [[MBProgressHUD alloc] initWithView:self.view];
InterNetConnectionService *netService=[[InterNetConnectionService alloc]init];
if(![netService checkFornetConnectionWithStatus])
{
[self.view addSubview:progressHud];
progressHud.mode = MBProgressHUDModeIndeterminate;
progressHud.labelText = @"Loading";
[progressHud show:YES];
for (Person *p in array_persons)
{
NSMutableDictionary *dict=[[NSMutableDictionary alloc]init];
[dict setObject:p.name forKey:@"Name"];
[dict setObject:p.address forKey:@"Address"];
NSString *photoResult=[self sendingPhototoServer:p.image];
[dict setObject:photoResult forKey:@"Photo"];
}
}
然後用ASIHTTP發送這個數組。
請你幫助我在這個for循環中異步上傳圖像並將其響應存儲在字典中。
謝謝。