24323

Question:
I want to select a image from Photo library or camera and have to save it into my photo album(If its already there i want to put 1 more copy)
-(IBAction) getPhoto:(id) sender {
UIImagePickerController * picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
if((UIButton *) sender == choosePhotoBtn) {
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
} else {
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
}
[self presentModalViewController:picker animated:YES];
}
-(IBAction) savePhoto:(id) sender
{
UIImage *myImage =UIImagePickerControllerSourceTypePhotoLibrary||UIImagePickerControllerSourceTypeCamera
UIImageWriteToSavedPhotosAlbum(myImage, self, @selector(image:didFinishSavingWithError:contextInfo:), nil);
printf("Hello world");
}
Here my savePhoto function os not working
Answer1:
UIImage *myImage =UIImagePickerControllerSourceTypePhotoLibrary||UIImagePickerControllerSourceTypeCamera
I don't know what it's doing here. In C / C++ the ||
operator always returns a bool (int), so it's definitely not an UIImage.
If the image picked from the UIImagePickerController is needed, implement the -imagePickerController:didFinishPickingMediaWithInfo:
method for the delegate, then read the UIImagePickerControllerEditedImage key of the info.
If a custom image needs to be saved, pass an actual UIImage.