how to solve this error of Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Source type 1 not available'

objective-c

Solution

Well, this means what it says. `UIImagePickerControllerSourceTypeCamera` is a value from enum, equal to 1. You're trying to run your code on simulator or on device, that doesn't have camera.

Problem

I have working on pick the photo from gallery and save in gallery my code is ``` -(void)onclicksave:(id)sender { NSLog(@"onclicksave"); UIImagePickerController *picker=[[UIImagePickerController alloc]init]; picker.delegate=self; if((UIButton *)sender== openLibrary) { picker.sourceType=UIImagePickerControllerSourceTypeSavedPhotosAlbum; } else { picker.sourceType=UIImagePickerControllerSourceTypeCamera; } [self presentModalViewController:picker animated:YES]; } -(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { [picker dismissModalViewControllerAnimated:YES]; imagedisplay.image=[info objectForKey:@"UIImagePickerControllerOriginalImage"]; } ``` but in this code run time error like Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Source type 1 not available' so give any suggestion and source code which is apply in my code

Original source