views:

206

answers:

0

I have a video in applications documents folder. I need it to be saved in camera roll. So, I used UISaveVideoAtPathToSavedPhotosAlbum method to save it in camera roll. It's working and I can see the video added to camera roll.

But, the problem is every time I execute the application with same video(with same file name), it is added another time in camera roll instead of replacing the old one. So, it is creating the duplicates of the video.

How can I make the application work like if a video is present in camera roll and again added with same file name, then old one is replaced by new video.

My code is:

 -(void)exportVideo:(id)sender
{
    NSString *path = [DOCUMENTS_FOLDER stringByAppendingString:@"/air.mp4"];
    NSLog(@"Path:%@", path);
    NSLog(@"Export Button CLicked");
    UISaveVideoAtPathToSavedPhotosAlbum(path, self, @selector(video:didFinishSavingWithError: contextInfo:), nil);
}

- (void)video:(NSString *)videoPath didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo 
{
    NSLog(@"Finished saving video with error: %@", error);
}  

Thank you.