0

I made an app that displays images from an AWS server. It's working fine for iPhone 4 and older but when I run my app on an iPhone 5 the app crashes when running using wifi or 3G connection. I did many tests that show me when I use S3GetObject...

3GetObjectResponse *getObjectResponse = [[AmazonClientManager s3] getObject:getObjectRequest];

UIImage *tampon = [[UIImage alloc] initWithData:getObjectResponse.body];

The app crashes, I don't know if the AWS-SDK is compatible with iOS 6 or not, please help me.

Mick MacCallum
  • 129,200
  • 40
  • 280
  • 281
Med Reda
  • 36
  • 1
  • 5
  • 1
    And what does the crash log say? – Mick MacCallum Oct 26 '12 at 13:41
  • there are no log because when i running the app connecting to mac that work fine but when i execute the app with connection wifi or 3g that crash = back in home screen of iphone – Med Reda Oct 26 '12 at 13:45
  • @MedReda I help maintain the AWS SDK for iOS and both the iPhone 5 and iOS6 are supported with the latest versions. It would be helpful if you could include the creation of the S3GetObjectRequest in your code snippet as how this is created can have effects on the response. Additionally, you can get logs from the crashed app by connecting the device after and go to Xcode > Organizer > Devices > Your Device > Device Logs. – Bob Kinney Oct 26 '12 at 19:33
  • My first guess would be that your getObjectResponse is nil due to connectivity issue – CitronEvanescent Oct 26 '12 at 14:34
  • No, any object can be sent any message when it is nil with no issue. The error lies elsewhere. – Richard J. Ross III Oct 26 '12 at 14:35
  • You do not know what is made with received object / properties. – CitronEvanescent Oct 26 '12 at 14:43

2 Answers2

2

Looks like you are using the AWS SDK with Grand Central Dispatch, and calling synchronous getObject: and updating UIs on the same thread. You need to make sure to call getObject: on a background thread, and update UIs on the main thread. Your code should look something like the following:

dispatch_async( dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{

    for(int i=0;i<ads.count;i++){

        NSString *phot =[ads objectAtIndex:i];
        NSLog(@"hna%@",phot);
        S3GetObjectRequest  *getObjectRequest  = [[S3GetObjectRequest alloc] initWithKey:phot   withBucket:@"olfactifPhoto"];
        S3GetObjectResponse *getObjectResponse = [[AmazonClientManager s3] getObject:getObjectRequest];

        dispatch_async( dispatch_get_main_queue(), ^{

            UIImage *tampon = [[UIImage alloc] initWithData:getObjectResponse.body];
            UIImageView *tempImageView = [[UIImageView alloc] initWithImage:tampon];
            tempImageView.frame = CGRectMake(10,currentXLocation, 300, 310);

            NSLog(@" il est dans la position %f",tempImageView.frame.origin.y);
            self.monImage = tempImageView;

            [scroll addSubview:monImage];
        });
    }

});
Yosuke
  • 3,759
  • 1
  • 11
  • 21
2

Based on one of your other questions, it appears you may still be including an older version of the AWS SDK for iOS which had problems with crashing when built for release because of the inclusion of the GTMLogger library.

Please make sure to remove any references to previous versions of the AWS SDK for iOS and also update your projects Framework include path.

You can confirm you are using the latest version of the SDK by logging the value returned from

[AmazonSDKUtil userAgentString]
Community
  • 1
  • 1
Bob Kinney
  • 8,870
  • 1
  • 27
  • 35