Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I found/created a solution that at least works for me. with the above method (<em>createRemoteDir</em>), the following code applied and worked for me:</p> <pre><code>NSError *error; createdDirectory = FALSE; /* only 'prepares' the stream for upload - doesn't actually upload anything until the runloop of this background thread is run */ [self createRemoteDir]; NSRunLoop *currentRunLoop = [NSRunLoop currentRunLoop]; do { if(![currentRunLoop runMode: NSDefaultRunLoopMode beforeDate: [NSDate distantFuture]]) { // log error if the runloop invocation failed error = [[NSError alloc] initWithDomain: @"org.mJae.FTPUploadTrial" code: 23 userInfo: nil]; } } while (!createdDirectory &amp;&amp; !error); // close stream, remove from runloop [ftpStream close]; [ftpStream removeFromRunLoop: [NSRunLoop currentRunLoop] forMode: NSDefaultRunLoopMode]; if (error) { // handle error } </code></pre> <p>It runs in a background thread and creates the directory on the ftp server. I like it more than other examples where runloops are only run for an assumed small interval, say 1second.</p> <pre><code>[NSDate distantFuture] </code></pre> <p>is a date in the futur (several centuries, according to Apples documentation). But that's good as the "break-condition" is handled by my class property <em>createdDirectory</em> - or the occurance of an error while starting the runloop.</p> <p>I can't explain why it works without me explicitly attaching an input source to the runloop (NSTimer or NSPort), but my guess is, it is sufficient that the NSOutputStream is scheduled in the runloop of the background thread (see <em>createRemoteDir</em>).</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.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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