Search code examples
iosiphonexcodephotolibrarysave-image

save image in photo album when button click in iphone


in My Application there is one galary. i dont know what to put in image(UIImage *image) part of the UIImageWriteToSavedPhotosAlbum Method and I wann save image in iphone photo album. I am using this code

- (void)savePhoto
{
    UIImageWriteToSavedPhotosAlbum(((IndicatorImageView *)[self._imageViews objectAtIndex:_selectedImage])._imageView.image, nil, nil, nil);

}

but it shows this error...

2012-10-26 18:48:00.596 PhotoGallery[2683:15203] -[GalleryItemView _imageView]: unrecognized selector sent to instance 0x8e7cc90 2012-10-26 18:48:00.665 PhotoGallery[2683:15203] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[GalleryItemView _imageView]: unrecognized selector sent to instance 0x8e7cc90' * First throw call stack:

Please help me if u know this... thanks in advance...


Solution

  • - (void)savePhoto
    {
        UIImageWriteToSavedPhotosAlbum(((IndicatorImageView *)[self.imageViews objectAtIndex:_selectedImage]).image, nil, nil, nil);
    }
    

    If your array self._imageViews contain imageViews , why you try to access _imageViewagain??

    also , Is _imageViews a property? use self.imageViews is better.