I use the following three delegate methods to pull images from S3. They are called in the presented order.
-(void)request:(AmazonServiceRequest *)request didReceiveResponse:(NSURLResponse *)response;
-(void)request:(AmazonServiceRequest *)request didReceiveData:(NSData *)data;
-(void)request:(AmazonServiceRequest *)request didCompleteWithResponse:(AmazonServiceResponse *)response;
I’ve noticed that if an image is large that sometimes the didReceieveResponse will get called before the previous didCompleteWithResponse has finished. This screws up the NSData received in the second delegate.
How do I fix this? All three are getting called in a for statement iteration for each iteration. like so:
for (NSString *name in array){
@try {
S3GetObjectRequest *gor = [[S3GetObjectRequest alloc]initWithKey:name withBucket:[Constants pictureBucket]];
[gor setDelegate:self];
[s3 getObject:gor];
}
I have not worked with S3 but I am sure that there would be some way of distinguishing the three different
AmazonServiceRequest *requestin the delegate functions(maybe the key you are using toinit). So you can take whatever action you are doing with theNSDataby first making a check on therequestyou are getting back in the delegate functions