0

I am trying to display an Logo image in my custom cell, from amazon Amazon S3 bucket though StackMob but its not showing. if l paste the direct url path to the image it works, how do i get around this.

NSManagedObject *object = [self.fetchedResultsController objectAtIndexPath:indexPath];

 CGRect imageFrame = CGRectMake(2, 2, 67, 67);

 self.customImage = [[UIImageView alloc] initWithFrame:imageFrame];

    NSURL* imageURL = [NSURL URLWithString:[object valueForKey:@"restoLogo"]];

    NSData *data = [[NSData alloc] initWithContentsOfURL:imageURL];

  UIImage *tmpImage = [[UIImage alloc] initWithData:data];

  self.customImage.image = tmpImage;
   [cell.contentView addSubview:self.customImage];

the image is at this path [object valueForKey:@"restoLogo"] now returns the s3 url for the data.

Cezar
  • 55,636
  • 19
  • 86
  • 87
mavusane
  • 247
  • 1
  • 2
  • 8

1 Answers1

1

If you are not using NSString's instance method

stringByAddingPercentEscapesUsingEncoding:

that could be the issue.

For example

NSString *escapedString = [imgURLString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

Then turn it into a URL and continue on your way.

Joel Fischer
  • 6,521
  • 5
  • 35
  • 46