2017-12-01 17 views
0

ギャラリーから複数の画像を選択していますが、これらの画像をWebサービスに投稿する必要がありますが、1つの画像しか投稿できない問題があります。この問題を解決するのに役立ちます。 ありがとう....ここ画像の配列に問題がありました

は私のコード

-(void)callingUploadBusinessBussinessGalleryImageApi{ 

    BusinessUser *busUser = [BusinessUser getBusinessUser]; 
    NSMutableArray *arrImgData = [[NSMutableArray alloc] init]; 

    for (int i = 0; i < self.chosenImages.count; i++) { 
    uploadImageData = UIImageJPEGRepresentation([self.chosenImages objectAtIndex:i], 0.1); 
    [arrImgData insertObject:uploadImageData atIndex:i]; 

    } 

    NSData *data = [NSKeyedArchiver archivedDataWithRootObject:arrImgData]; 

    //NSData *data =[NSPropertyListSerialization dataWithPropertyList:arrImgData format:NSPropertyListBinaryFormat_v1_0 options:0 error:nil]; 
    NSURL *uploadProfPicUrl = [NSURL URLWithString:BaseUrl]; 
    NSMutableDictionary *dataDictionary = [[NSMutableDictionary alloc] init]; 
    [dataDictionary setValue:[NSNumber numberWithLong:busUser.business_id] forKey:@"business_id"]; 
    NetworkHandler *networkHandler = [[NetworkHandler alloc] initWithRequestUrl:uploadProfPicUrl withBody:dataDictionary withMethodType:HTTPMethodPOST withHeaderFeild:nil]; 
    [networkHandler startUploadRequest:@"DirectoryProfilePhoto" withData:data withType:fileTypeJPGImage withUrlParameter:uploadBusinessGalleryImageUrl withFileLocation:@"imageFile" SuccessBlock:^(id responseObject) { 
     NSLog(@"%@", responseObject); 
    } ProgressBlock:^(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite) { 

    } FailureBlock:^(NSString *errorDescription, id errorResponse) { 

    }]; 
} 

は、ここで私は画像の配列を送信する必要があるサーバへの単一の画像のみの投稿です...

答えて

0

はあなたがでそれらを1つずつ送信する必要がありますアプリケーションをフリーズさせたくない場合はバックグラウンドキューに1つe。

次の手順に従います。 1.アレイの最初のイメージをアップロードする機能を呼び出します。あなたがアップロードされている第1の画像の応答を取得

[self uploadingMethod]; 

-(void)uploadingMethod 
    { 
     //Hit the uploading service here. 

     [self uploadtask:0]; //0 being the index of the array 

    } 

-(void)uploadtask:(int*)IndexNumber 
{ 
    //Upload the image in background thread. 
} 

たら、2.再配列のインクリメントインデックスにアップロード機能が、この時間を呼び出します。

-(void)uploadingMethod 
    { 
     //Hit the uploading service here. 

     [self uploadtask:1]; //increment this everytime the function is called. 

    } 
+0

私の質問はここで私は一つだけの画像を投稿することができ、画像 – ammu

+0

のアップロード配列であるが、O ahve – ammu

+0

は、その後、あなたのアップロードのコードを変更し、AFのネットワークを使用する必要があります画像の配列を投稿します。 これを次のように使用してください:https://stackoverflow.com/a/18204164/6597313 –

関連する問題