Question

I got this error when I wrote the code mentioned below.Basically I want to save video captured by UIImagePickerController to my app directory.I am not getting where I've made mistake.Please help me..

- (void) imagePickerController: (UIImagePickerController *) picker didFinishPickingMediaWithInfo: (NSDictionary *) info
{
    NSString *mediaType = [info objectForKey: UIImagePickerControllerMediaType];
    [self dismissModalViewControllerAnimated:NO];
    // Handle a movie capture
    if (CFStringCompare ((__bridge_retained CFStringRef) mediaType, kUTTypeMovie, 0) == kCFCompareEqualTo)
    {
        NSArray  *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
        NSString *documentsDir  = [documentPaths objectAtIndex:0];
        NSString *movieName = [NSString stringWithFormat:@"%@.mov",[self getNameForVideo]];
        NSString *moviePath    = [documentsDir stringByAppendingPathComponent:movieName];
        NSURL * movieURL = [info valueForKey:UIImagePickerControllerMediaURL];
        NSData * movieData = [NSData dataWithContentsOfURL:movieURL];
        if([movieData writeToFile:moviePath atomically:NO])
        {
            [self saveVideoInfoInDatabase];
        }
        else
        {
            NSLog(@"Video could not be saved to the document directry");
        }
    }
}
Was it helpful?

Solution

It is cause of memory constraints (which manifest themselves in various ways). It's also possible that it's the cause of threaded interaction behaviour between when the downloads finishes and the UI at the time. Some people have indicated that there are issues with displaying a UIAlertView and creating a UIWebView, when the latter is created before the former. If you have a quick download connection (which is likely to be the case in the simulator and a local web server) then you might find it's the fact that your download is finishing too quickly for the UI to be ready to display a notification that the download is complete.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top