im trying to download an image file and save it to phot albums as following
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        NSLog(@"Downloading Started");
        NSString *urlToDownload = @"http://wallpapercave.com/wp/66iglE0.jpg";
        NSURL  *url = [NSURL URLWithString:urlToDownload];
        NSData *urlData = [NSData dataWithContentsOfURL:url];
        if ( urlData )
        {
            NSArray  *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
            NSString  *documentsDirectory = [paths objectAtIndex:0];
            NSString  *filePath = [NSString stringWithFormat:@"%@/%@", documentsDirectory,@"filename.jpg"];
            dispatch_async(dispatch_get_main_queue(), ^{
                [urlData writeToFile:filePath atomically:YES];
                NSLog(@"File Saved !");
                NSData *retrievedData = [NSData dataWithContentsOfFile:filePath];
               ;
                dispatch_async(dispatch_get_main_queue(), ^{
                    UIImageWriteToSavedPhotosAlbum( [UIImage imageWithData:retrievedData],
                                                   self,
                                                   @selector(done),
                                                   NULL);                });
            });
        } else {
            dispatch_async(dispatch_get_main_queue(), ^{
                NSLog(@"Failed");
            });
        }
    });
But im getting the following error,
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSInvocation setArgument:atIndex:]: index (2) out of bounds [-1, 1]' *** First throw call stack: (0x1816751b8 0x1800ac55c 0x18156db24 0x18c4ff9b0 0x18c500570 0x18bdd8ddc 0x100a45258 0x100a45218 0x100a4a280 0x181622810 0x1816203fc 0x18154e2b8 0x183002198 0x1875957fc 0x187590534 0x1000bcac8 0x1805315b8) libc++abi.dylib: terminating with uncaught exception of type NSException
How will i be able to sort this out?
 
     
     
     
     
     
    