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 Build a Self-Destructing Message iPhone App Capturing Photo and Video Using UIImagePickerController Saving the Media

UIImageWriteToSavedPhotosAlbum(self.imagePicker, nil, nil, nil);

This method gives me warning and crashes my app

3 Answers

 Vladimir Cezar
 Vladimir Cezar
7,710 Points

Can you upload the project to a github account? I could take a look then.

I have never done it. when I try to take picture with my iphone and click on use button the app crashes immediately

thanks for quick reply

Here is the code

´´´

  • (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {

    NSString *mediaType = [info objectForKey:UIImagePickerControllerMediaType];

    if ([mediaType isEqualToString:(NSString*)kUTTypeImage]) { // A photo was taken/selected! self.image = [info objectForKey:UIImagePickerControllerOriginalImage]; if (self.imagePicker.sourceType == UIImagePickerControllerSourceTypeCamera) { // Save the image! UIImageWriteToSavedPhotosAlbum(self.imagePicker, nil, nil, nil); <==== This line give me warning } [self dismissViewControllerAnimated:YES completion:nil]; } else { // A video was taken/selected! NSURL *imagePickerURL = [info objectForKey:UIImagePickerControllerMediaURL]; self.videoFilePath = [imagePickerURL path]; if (self.imagePicker.sourceType == UIImagePickerControllerSourceTypeCamera) { // Save the video! if (UIVideoAtPathIsCompatibleWithSavedPhotosAlbum(self.videoFilePath)) { UISaveVideoAtPathToSavedPhotosAlbum(self.videoFilePath, nil, nil, nil); } } } [self dismissViewControllerAnimated:YES completion:nil]; }

´´´

 Vladimir Cezar
 Vladimir Cezar
7,710 Points

It is really hard to bug fix without the whole project. Github will be the best way.

I have never uploaded project on github, I'll try anyway. thanks for your time, appreciate it.

this method = (Deprecated in iOS 7.0.)

thumbnailImageAtTime:timeOption:

Deprecated in iOS 7.0

thumbnailImageAtTime:timeOption: Captures and returns a thumbnail image from the current movie. (Deprecated in iOS 7.0.)

I think they need to update the course.

 Vladimir Cezar
 Vladimir Cezar
7,710 Points

Github can be intimidating at beginning, but don't be. Take a course here at Treehouse on how to use git. Believe me, it is a skill you will use over and over. All the best.