To answer the first part of my question…
This (deliberately set) locked state is the same as the Finder's locked state. 
You can get it using -[NSURL getResourceValue:forKey:error:] with the key, 
NSURLIsUserImmutableKey.

So you need to check both the NSURLIsUserImmutableKey file-attribute and the 
checkAutosavingSafetyAndReturnError document heuristic in order to know whether 
"Locked" is displayed in the document's title bar.

As for notifications -
It seems autosaveWithImplicitCancellability is called when the user locks the 
file from title bar menu, but not when the user unlocks the file. Makes sense; 
however, *unlocking a locked file* is the transition I am interested in. I 
suppose I can poll for it, but ick!

Is there a better way to be notified when a file's attributes change?

Thanks,
Dave

On 2011-11-16, at 1:31 PM, Dave Fernandes wrote:

> SUMMARY
> I'd like to know when a document is in the "locked" state. Cocoa provides 
> -[NSDocument checkAutosavingSafetyAndReturnError:]; but this only seems to 
> tell me when the heuristics think the document should be locked, not when the 
> user has deliberately locked the document. Is there any way to determine the 
> actual locked state, or receive a notification when it changes?
> 
> PROBLEM
> I have a document-bases app where documents conceptually contain widgets and 
> other data. The widget properties are managed from an application (singleton) 
> library. Normally, the user would expect the widgets to always be in sync 
> with this library. However, when the document is locked or emailed to someone 
> else (who may have a quite different widget library), the document should 
> retain the widget properties as they existed in the library when the document 
> was locked.
> 
> This means the document must contain a copy of any widgets it uses. It also 
> means that either the app must automatically "sync" the document's widgets 
> with the library at appropriate times, or the user must do this her/himself. 
> Since, the user almost always wants the two to be in sync, I would much 
> rather the application do this automatically. Thus, the app needs to know 
> when this is appropriate, and so, needs to know the locked state.
> 
> But if you can think of a better application design, I'd be happy to hear it.
> 
> Dave_______________________________________________
> 
> Cocoa-dev mailing list ([email protected])
> 
> 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:
> http://lists.apple.com/mailman/options/cocoa-dev/dave.fernandes%40utoronto.ca
> 
> This email sent to [email protected]

_______________________________________________

Cocoa-dev mailing list ([email protected])

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to