Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS

self dESTRUCTING MESSAGE APP

I still can't view my image in simulator when i click on a message in my inbox, i checked everything like the inbox.m and image.m files along with .h's ???? I need Help now???:)

Retrieved 4 messages 2014-01-20 13:42:19.189 Vista[9037:70b] Could not load the "Username" image referenced from a nib in the bundle with identifier "Meco-INC..Vista" 2014-01-20 13:42:29.668 Vista[9037:70b] Retrieved 4 messages THIS IS ERROR WHEN I CLICK ON MESSAGE IN MY INBOX

Just throwing a dart at this problem... did you check the

[Parse setApplicationId:@"list of numbers and letters"
      clientKey: more numbers and letters 

This info can be found in the Appdelegate.m file.

6 Answers

Marsela,

You may want to clean your build folder. Usually loading assets through Xcode's visual tools (Interface Builder, etc.) can cause hiccups in your code. To clean your build folder, simply go to Product > Clean.

Let us know if this helps!

tried it, didn't work at all, idk :(

If you attach your project files, I'll try my best and take a look.

import "InboxViewController.h"

import "ImageViewController.h"

@interface InboxViewController ()

@end

@implementation InboxViewController

  • (void)viewDidLoad { [super viewDidLoad];

    self.moviePlayer = [[MPMoviePlayerController alloc] init];

    PFUser *currentUser = [PFUser currentUser]; if (currentUser) { NSLog(@"Current user: %@", currentUser.username); } else { [self performSegueWithIdentifier:@"showLogin" sender:self]; } }

  • (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated];

    PFQuery *query = [PFQuery queryWithClassName:@"Messages"]; [query whereKey:@"recipientIds" equalTo:[[PFUser currentUser] objectId]]; [query orderByDescending:@"createdAt"]; [query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) { if (error) { NSLog(@"Error: %@ %@", error, [error userInfo]); } else { // We found messages! self.messages = objects; [self.tableView reloadData]; NSLog(@"Retrieved %d messages", [self.messages count]); } }]; }

pragma mark - Table view data source

  • (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { // Return the number of sections. return 1; }

  • (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { // Return the number of rows in the section. return [self.messages count]; }

  • (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];

    PFObject *message = [self.messages objectAtIndex:indexPath.row]; cell.textLabel.text = [message objectForKey:@"senderName"];

    NSString *fileType = [message objectForKey:@"fileType"]; if ([fileType isEqualToString:@"image"]) { cell.imageView.image = [UIImage imageNamed:@"icon_image"]; } else { cell.imageView.image = [UIImage imageNamed:@"icon_video"]; }

    return cell; }

pragma mark - Table view delegate

  • (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *) indexPath { self.selectedMessage = [self.messages objectAtIndex:indexPath.row]; NSString *fileType = [self.selectedMessage objectForKey:@"fileType"]; if ([fileType isEqualToString:@"image"]) { [self performSegueWithIdentifier:@"showImage" sender:self]; } else { // File type is video PFFile *videoFile = [self.selectedMessage objectForKey:@"file"]; NSURL *fileUrl = [NSURL URLWithString:videoFile.url]; self.moviePlayer.contentURL = fileUrl; [self.moviePlayer prepareToPlay]; [self.moviePlayer thumbnailImageAtTime:0 timeOption: MPMovieTimeOptionNearestKeyFrame];

    // Add it to the view controller so we can see it
    [self.view addSubview:self.moviePlayer.view];
    [self.moviePlayer setFullscreen:YES animated:YES];
    

    }

    // Delete it! NSMutableArray *recipientIds = [NSMutableArray arrayWithArray:[self. selectedMessage objectForKey:@"recipientIds"]]; NSLog(@"Recipients: %@", recipientIds);

    if ([recipientIds count] == 1) { // Last recipient - delete! [self.selectedMessage deleteInBackground]; } else { // Remove the recipient and save it [recipientIds removeObject:[[PFUser currentUser] objectId]]; [self.selectedMessage setObject:recipientIds forKey:@"recipientIds"]; [self.selectedMessage saveInBackground]; } }

  • (IBAction)logout:(id)sender { [PFUser logOut]; [self performSegueWithIdentifier:@"showLogin" sender:self];

}

  • (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { if ([segue.identifier isEqualToString:@"showLogin"]) { [segue.destinationViewController setHidesBottomBarWhenPushed:YES]; } else if ([segue.identifier isEqualToString:@"showImage"]) { [segue.destinationViewController setHidesBottomBarWhenPushed:YES]; ImageViewController *imageViewController = (ImageViewController *)segue. destinationViewController; imageViewController.message = self.selectedMessage; } }

@end this is the inbox view.m

import "ImageViewController.h"

@interface ImageViewController ()

@end

@implementation ImageViewController

  • (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; }

  • (void)viewDidAppear:(BOOL)animated { [super viewWillAppear:animated];

    if ([self respondsToSelector:@selector(timeout)]) { [NSTimer scheduledTimerWithTimeInterval:10 target:self selector:@selector (timeout)userInfo:nil repeats:NO]; } else { NSLog(@"Error:selector missing!"); } }

pragma mark - Helper methods

  • (void)timeout { [self.navigationController popViewControllerAnimated:YES]; }

@end

this is the image view.m

This is my error at bottom:2014-01-24 15:01:09.812 Vista[1390:70b] Current user: Erdi Meco 2014-01-24 15:01:10.396 Vista[1390:70b] Retrieved 0 messages 2014-01-24 15:01:26.604 Vista[1390:70b] Retrieved 0 messages 2014-01-24 15:01:32.028 Vista[1390:70b] Retrieved 0 messages 2014-01-24 15:01:35.799 Vista[1390:70b] Could not load the "Username" image referenced from a nib in the bundle with identifier "Meco-INC..Vista" 2014-01-24 15:01:38.569 Vista[1390:70b] Could not load the "Username" image referenced from a nib in the bundle with identifier "Meco-INC..Vista" Jan 24 15:01:42 erdis-mbp Vista[1390] <Error>: CGContextSetFillColorWithColor: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update. Jan 24 15:01:42 erdis-mbp Vista[1390] <Error>: CGContextSetStrokeColorWithColor: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update. Jan 24 15:01:42 erdis-mbp Vista[1390] <Error>: CGContextSaveGState: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update. Jan 24 15:01:42 erdis-mbp Vista[1390] <Error>: CGContextSetFlatness: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update. Jan 24 15:01:42 erdis-mbp Vista[1390] <Error>: CGContextAddPath: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update. Jan 24 15:01:42 erdis-mbp Vista[1390] <Error>: CGContextDrawPath: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update. Jan 24 15:01:42 erdis-mbp Vista[1390] <Error>: CGContextRestoreGState: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update. Jan 24 15:01:42 erdis-mbp Vista[1390] <Error>: CGContextSaveGState: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update. Jan 24 15:01:42 erdis-mbp Vista[1390] <Error>: CGContextSetFlatness: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update. Jan 24 15:01:42 erdis-mbp Vista[1390] <Error>: CGContextAddPath: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update. Jan 24 15:01:42 erdis-mbp Vista[1390] <Error>: CGContextDrawPath: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update. Jan 24 15:01:42 erdis-mbp Vista[1390] <Error>: CGContextRestoreGState: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update. Jan 24 15:01:42 erdis-mbp Vista[1390] <Error>: CGContextSetFillColorWithColor: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update. Jan 24 15:01:42 erdis-mbp Vista[1390] <Error>: CGContextSetStrokeColorWithColor: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update. Jan 24 15:01:42 erdis-mbp Vista[1390] <Error>: CGContextSetFillColorWithColor: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update. Jan 24 15:01:42 erdis-mbp Vista[1390] <Error>: CGContextSetStrokeColorWithColor: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update. Jan 24 15:01:42 erdis-mbp Vista[1390] <Error>: CGContextGetBlendMode: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update. Jan 24 15:01:42 erdis-mbp Vista[1390] <Error>: CGContextSetBlendMode: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update. Jan 24 15:01:42 erdis-mbp Vista[1390] <Error>: CGContextFillRects: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update. Jan 24 15:01:42 erdis-mbp Vista[1390] <Error>: CGContextSetBlendMode: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update. Jan 24 15:01:42 erdis-mbp Vista[1390] <Error>: CGContextSetFillColorWithColor: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update. Jan 24 15:01:42 erdis-mbp Vista[1390] <Error>: CGContextSetStrokeColorWithColor: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update. Jan 24 15:01:42 erdis-mbp Vista[1390] <Error>: CGContextGetBlendMode: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update. Jan 24 15:01:42 erdis-mbp Vista[1390] <Error>: CGContextSetBlendMode: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update. Jan 24 15:01:42 erdis-mbp Vista[1390] <Error>: CGContextFillRects: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update. Jan 24 15:01:42 erdis-mbp Vista[1390] <Error>: CGContextSetBlendMode: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update. Jan 24 15:01:42 erdis-mbp Vista[1390] <Error>: CGContextSetFillColorWithColor: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update. Jan 24 15:01:42 erdis-mbp Vista[1390] <Error>: CGContextSetStrokeColorWithColor: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update. Jan 24 15:01:42 erdis-mbp Vista[1390] <Error>: CGContextGetBlendMode: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update. Jan 24 15:01:42 erdis-mbp Vista[1390] <Error>: CGContextSetBlendMode: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update. Jan 24 15:01:42 erdis-mbp Vista[1390] <Error>: CGContextFillRects: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update. Jan 24 15:01:42 erdis-mbp Vista[1390] <Error>: CGContextSetBlendMode: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update. 2014-01-24 15:01:53.099 Vista[1390:70b] Retrieved 0 messages