Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>just create a link to that file, then use NSURLConnection to download.</p> <p>Create a URL connection to download:</p> <pre><code>NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init]; [request setURL:[NSURL URLWithString:strFileUrl]]; //strFileURL is url of your video/image NSURLConnection *conection = [[[NSURLConnection alloc] initWithRequest:request delegate:self startImmediately:NO] autorelease]; [conec start]; [request release]; </code></pre> <p>Get path of file to save data:</p> <pre><code>strFilePath = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0] stringByAppendingPathComponent:strFileName]; </code></pre> <p>Your class must adopt 3 methods of NSURLConnectionDelegate protocol: (please read about Protocol and Delegate)</p> <pre><code> - (void) connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response { // create [[NSFileManager defaultManager] createFileAtPath:strFilePath contents:nil attributes:nil]; file = [[NSFileHandle fileHandleForUpdatingAtPath:strFilePath] retain];// read more about file handle if (file) { [file seekToEndOfFile]; } } - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)receivedata { //write each data received if( receivedata != nil){ if (file) { [file seekToEndOfFile]; } [file writeData:receivedata]; } } - (void)connectionDidFinishLoading:(NSURLConnection*)theConnection { //close file after finish getting data; [file closeFile]; } - (void) connection:(NSURLConnection *)connection didFailWithError:(NSError *)error { //do something when downloading failed } </code></pre> <p>If you want to review you file, use a UIWebview to load it:</p> <pre><code> NSURL *fileURL = [NSURL fileURLWithPath:strFilePath]; [wvReview loadRequest:[NSURLRequest requestWithURL:fileURL]]; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload