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
Dee Greene
8,508 Pointsimages not showing after Xcode and iOS 9 update
I am creating an application similar to the "Ribbit" Objective-C app. I have recently updated xCode and had to deal with various issues/warnings since. On major error now is that when clicking on a cell in my inbox the image is blank when transitioning to the next page.
InboxTableViewController.m
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
self.selectedMessage = [self.messages objectAtIndex:indexPath.row];
// mark message as read
NSMutableArray *readByIds = [NSMutableArray arrayWithArray:[self.selectedMessage objectForKey:@"readBy"]];
[readByIds addObject:[[PFUser currentUser] objectId]];
[self.selectedMessage setObject:readByIds forKey:@"readBy"];
[self.selectedMessage saveInBackground];
NSString *fileType = [self.selectedMessage objectForKey:@"fileType"];
if ([fileType isEqualToString:@"image"]) {
// file type is 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];
}
}
ImageViewController.m
- (void)viewDidLoad {
[super viewDidLoad];
NSString *senderName = [self.message objectForKey:@"senderEmail"];
self.navigationItem.title = senderName;
// download image from Parse.com
PFFile *imageFile = [self.message objectForKey:@"file"];
NSURL *imageFileUrl = [[NSURL alloc] initWithString:imageFile.url];
NSData *imageData = [NSData dataWithContentsOfURL:imageFileUrl];
//set the image view to the message image
self.imageView.image = [UIImage imageWithData:imageData];
}
3 Answers
Martin Wildfeuer
Courses Plus Student 11,071 PointsWith iOS9 Apple significantly raised the security level of networking, TLSv1.2 SSL is now required for every server call by default. All exceptions have to be defined in the info.plist. I'll give you a few links that may help you:
Cory Bowman
1,432 PointsCould someone please show me how to fix the error?
Dee Greene
8,508 PointsThe easiest way I know is to edit your info.plist file.
Add: Key: NSExceptionDomains Type: Dictionary
- Key: NSAllowsArbitraryLoads Type: Boolean Value: YES
However...this is not the "best" way to do it. But it should fix your error for now
Cory Bowman
1,432 PointsThanks
Dee Greene
8,508 PointsNo problem!
Dee Greene
8,508 PointsDee Greene
8,508 PointsThank you. This helped so much. The error messages I was getting weren't really leading me anywhere lol But gave your suggestion a shot and the images are now appearing!