Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Here's native code for pulling imagers from S3. The first is the implementation of h of the custom S3 delegate. The second is the m file to get the objects from S3. The final method should be in the class of the table you want to display the pics in.</p> <pre><code>@protocol S3ObjectControllerDelegate -(void)S3ControllerFinished:(NSString *)objectKey; @end @interface S3ObjectController :NSObject &lt;AmazonServiceRequestDelegate&gt;{ NSMutableData *responseData; NSString *keyName; AmazonS3Client *s3Client; S3GetObjectRequest *s3GOR; id &lt;S3ObjectControllerDelegate&gt; delegate; } -(void)s3GetRacerPictuers; @property (nonatomic, strong) NSString *keyName; @property (nonatomic, strong) UIImage *image; @property (nonatomic, strong) id &lt;S3ObjectControllerDelegate&gt; delegate; //was assign @end @implementation S3ObjectController @synthesize keyName,image; @synthesize delegate; -(void)request:(AmazonServiceRequest *)request didFailWithError:(NSError *)error { NSLog(@"Error %@",error); } -(void)request:(AmazonServiceRequest *)request didReceiveResponse:(NSURLResponse *)response { //NSLog(@"Response Key %@", response); responseData = [[NSMutableData alloc]init]; } -(void)request:(AmazonServiceRequest *)request didReceiveData:(NSData *)data { //NSLog(@"ObjectRequestKey = %@",request); [responseData appendData:data]; } -(void)request:(AmazonServiceRequest *)request didCompleteWithResponse:(AmazonServiceResponse *)response { UIImage *myImage = [[UIImage alloc]initWithData:responseData]; if(myImage == nil) { //NSLog(@"NO IMAGE"); image = [UIImage imageNamed:@"placeholder.png"]; responseData = nil; } else { //NSLog(@"image added"); image = myImage; responseData = nil; } [[self delegate] S3ControllerFinished:keyName]; } -(void)s3GetPictuers { // NSLog(@"Method Called"); s3Client = [[AmazonS3Client alloc] initWithAccessKey:ACCESS_KEY_ID withSecretKey:SECRET_KEY]; s3GOR = [[S3GetObjectRequest alloc]initWithKey:keyName withBucket:[Constants pictureBucket]]; s3GOR.delegate = self; [s3Client getObject:s3GOR]; //NSLog(@"Method Finished"); } @end -(void)S3ControllerFinished:(NSString *)objectKey { S3ObjectController *newS3 = [[S3ObjectController alloc] init]; newS3 = [tempDictionary objectForKey:objectKey]; UIImage *tempImage = newS3.image; [dictionaryOfImages setObject:tempImage forKey:objectKey]; [table reloadData]; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload