I have a dirty document that needs to be cleared programmatically. So I try the 
following but it does not work. I have verified that updateChangeCount: is 
being called but the document change count state is not being changed. This 
code is executed on the main thread.

    // Called from a controller.
    // This does not work.
    NSDocument *doc = self.myDocument;
    [doc updateChangeCount:NSChangeUndone];

So next I try the following. When a function key is pressed the following code 
is executed. This is exactly the same as before but it now works! The document 
is no longer dirty. This code is also executed on the main thread.

    // Called with a function key press.
    // This works fine.
    NSDocument *doc = self.myDocument;
    [doc updateChangeCount:NSChangeUndone];

So next I try the following using performSelector. But this does not work at 
all when called from a controller or when called with a function key press.

    // This does not work at all.
    NSDocument *doc = self.myDocument;
    [doc performSelector:@selector(updateChangeCount:)
              withObject:@(NSChangeUndone)
              afterDelay:0];

So why does successfully calling -[NSDocument  updateChangeCount:] have a 
hidden dependency on the run loop?

--Richard Charles


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to