Note that there are some explanatory texts on larger screens.

plurals
  1. POupload files in background via ftp on iphone
    primarykey
    data
    text
    <p>i'm trying to establish an FTP connection within an app. i want to upload several files to a FTP server, all files in one directory. So at first i want to create the remote directory.</p> <pre><code>- (void) createRemoteDir { NSURL *destinationDirURL = [NSURL URLWithString: uploadDir]; CFWriteStreamRef writeStreamRef = CFWriteStreamCreateWithFTPURL(NULL, (__bridge CFURLRef) destinationDirURL); assert(writeStreamRef != NULL); ftpStream = (__bridge_transfer NSOutputStream *) writeStreamRef; BOOL success = [ftpStream setProperty: ftpUser forKey: (id)kCFStreamPropertyFTPUserName]; if (success) { NSLog(@"\tsuccessfully set the user name"); } success = [ftpStream setProperty: ftpPass forKey: (id)kCFStreamPropertyFTPPassword]; if (success) { NSLog(@"\tsuccessfully set the password"); } ftpStream.delegate = self; [ftpStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; // open stream [ftpStream open]; } </code></pre> <p>This code doesn't work when executed in a background thread using the following call:</p> <pre><code>[self performSelectorInBackground: @selector(createRemoteDir) withObject: nil]; </code></pre> <p>my guess is that the (background-threads) runloop isn't running? If i send the message inside the main thread the uploading just works fine:</p> <pre><code>[self createRemoteDir]; </code></pre> <p>as the runloop of the main thread is up and running.</p> <p>but fairly large files are going to be uploaded; so i want to put that workload in a background thread. but how and where do i set up the NSRunLoop, so that the whole uploading happens in a background thread? Apples documentation on NSRunLoops (especially how to start them without using a timer/input source, as in this case) didn't help me out.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    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