Note that there are some explanatory texts on larger screens.

plurals
  1. POmain in my NSOperation subclass not being called
    primarykey
    data
    text
    <p>I subclassed NSOperation and implemented the main method. When I added it to an NSOperationQueue, it was not being called. I compared it to sample code and sample projects that <em>do</em> work and could not see what the problem was. Does anyone have any experience with this problem and what causes it, please?</p> <p>After going crazy trying to find the problem, I decided to start over from scratch, rebuild my class and test it at each step. In the header, I declared it a subclass of NSOperation. In the implementation file, I implemented main and only put a couple of lines: <code>sleep(3)</code>; <code>NSLog..;</code>. All good. Each step worked as I started to add properties, even declared delegate, etc.</p> <p>Finally, in the main, I put code to use NSDirectoryEnumerator. Suddenly, main was not being called at all. Not only that, when I took that code back out, it still does not work!! I tried restarting XCode 4, restarting my machine (not that I know why these might help, but I'm running out of ideas) but all to no avail.</p> <p>Any clues at all would be most appreciated. Thanks.</p> <hr> <p>Update: I started over (again!) from scratch but this time I assembled the parts in a different order... and now it works! However, in case there is something that I'm doing wrong anyway and I've just been lucky this time round, here is the @interface section as @Andrew suggested:</p> <pre><code>@class ScanOperation; @protocol ScanOperationDelegate -(void)fileFound:(ScanOperation *)operation; -(void)finishedScanOperation:(ScanOperation *)operation; @end #import &lt;Foundation/Foundation.h&gt; @interface ScanOperation : NSOperation { @private NSObject &lt;ScanOperationDelegate&gt; *delegate; NSURL *rootUrl; int totCount, dirCount, filCount, errCount; NSTimeInterval elapsed; } - (id)initWithScanRootUrl:(NSURL *)startAtUrl; @property (readwrite, assign) NSObject &lt;ScanOperationDelegate&gt; *delegate; @property (readonly) int totCount, dirCount, filCount, errCount; @property (readonly) NSTimeInterval elapsed; @end </code></pre>
    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.
 

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