Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

iOS

Self Destructing App - Viewing sent image file

Hi,

I have a problem displaying the image file when i click on the sender in Inbox. First of all, Xcode was giving me an error when i used a code as shown in the video. "NSURL *imageFileUrl =[ [NSURL alloc] initWithString: imageFile.url]; " so I replaced it with: "NSURL *imageFileUrl = [NSURL URLWithString:imageFile.url];". That worked for the error, but still there is no image retrieved from the Parse.com, but rather blank page appears, and instead of "Sent from 'sender'", I get "Sent from (null)" in the header. Im guessing there is a problem with communication with Parse.com, but the number of contacts and messages on Parse.com is updated whenever I do something with the app.

Any suggestions? Thanks all

2 Answers

Michael Reining
Michael Reining
10,101 Points

Everything worked for me when I followed the instructions. Did you manage to solve your problem? If not, perhaps it might help to copy and paste the entire viewDidLoad method. It could be that the mistake is caused by an error or typo in one of the other items.

Here is what I wrote down and it's working on my iPhone when I run the app.

- (void)viewDidLoad
{
    [super viewDidLoad];
    PFFile *imageFile = [self.message objectForKey:@"file"];
    NSURL *imageFileUrl = [[NSURL alloc] initWithString:imageFile.url];
    NSData *imageData = [NSData dataWithContentsOfURL:imageFileUrl];
    self.imageView.image = [UIImage imageWithData:imageData];
    NSString *senderName = [self.message objectForKey:@"senderName"];
    NSString *title = [NSString stringWithFormat:@"Sent from %@",senderName];
    self.navigationItem.title = title;

    // Do any additional setup after loading the view.
}

I hope that helps

Yeah, it all good, managed to fix it. Thanks Mike