title: NSFilePresenter methods never get called
body: <p>I'm trying to write a simple (toy) program that uses the NSFilePresenter and NSFileCoordinator methods to watch a file for changes.</p>
  
  <p>The program consists of a text view that loads a (hardcoded) text file and a button that will save the file with any changes. The idea is that I have two instances running and saving in one instance will cause the other instance to reload the changed file.</p>
  
  <p>Loading and saving the file works fine but the NSFilePresenter methods are never called. It is all based around a class called FileManager which implements the NSFilePresenter protocol. The code is as follows:</p>
  
  <p>Interface:</p>
  
  <pre><code>@interface FileManager : NSObject &lt;NSFilePresenter&gt;
  @property (unsafe_unretained) IBOutlet NSTextView *textView;
  
  - (void) saveFile;
  - (void) reloadFile;
  
  @end
  </code></pre>
  
  <p>Implementation:</p>
  
  <pre><code>@implementation FileManager
  {
      NSOperationQueue* queue;
      NSURL* fileURL;
  }
  
  - (id) init {
      self = [super init];
      if (self) {
          self-&gt;queue = [NSOperationQueue new];
          self-&gt;fileURL = [NSURL URLWithString:@"/Users/Jonathan/file.txt"];
          [NSFileCoordinator addFilePresenter:self];
      }
      return self;
  }
  
  - (NSURL*) presentedItemURL {
      NSLog(@"presentedItemURL");
      return self-&gt;fileURL;
  }
  
  - (NSOperationQueue*) presentedItemOperationQueue {
      NSLog(@"presentedItemOperationQueue");
      return self-&gt;queue;
  }
  
  - (void) saveFile {
      NSFileCoordinator* coordinator = [[NSFileCoordinator alloc] initWithFilePresenter:self];
      NSError* error;
      [coordinator coordinateWritingItemAtURL:self-&gt;fileURL options:NSFileCoordinatorWritingForMerging error:&amp;error byAccessor:^(NSURL* url) {
          NSString* content = [self.textView string];
          [content writeToFile:[url path] atomically:YES encoding:NSUTF8StringEncoding error:NULL];
      }];
  }
  
  - (void) reloadFile {
      NSFileManager* fileManager = [NSFileManager defaultManager];
      NSFileCoordinator* coordinator = [[NSFileCoordinator alloc] initWithFilePresenter:self];
      NSError* error;
      __block NSData* content;
      [coordinator coordinateReadingItemAtURL:self-&gt;fileURL options:0 error:&amp;error byAccessor:^(NSURL* url) {
          if ([fileManager fileExistsAtPath:[url path]]) {
              content = [fileManager contentsAtPath:[url path]];
          }
      }];
      dispatch_async(dispatch_get_main_queue(), ^{
          [self.textView setString:[[NSString alloc] initWithData:content encoding:NSUTF8StringEncoding]];
      });
  }
  
  // After this I implement *every* method in the NSFilePresenter protocol. Each one
  // simply logs its method name (so I can see it has been called) and calls reloadFile
  // (not the correct implementation for all of them I know, but good enough for now).
  
  @end
  </code></pre>
  
  <p>Note, reloadFile is called in <code>applicationDidFinishLaunching</code> and saveFile gets called every time the save button is click (via the app delegate).</p>
  
  <p>The only NSFilePresenter method that ever gets called (going by the logs) is presentedItemURL (which gets called four times when the program starts and loads the file and three times whenever save is clicked. Clicking save in a second instance has no noticeable effect on the first instance.</p>
  
  <p>Can anyone tell me what I'm doing wrong here?</p>