Implement the shouldEnableURL
delegate method as follows:
- (BOOL)panel:(id)sender shouldEnableURL:(NSURL *)url
{
return [[NSFileManager defaultManager] isWritableFileAtPath:[url path]];
}
This will render all non-writable paths as unselectable in the open panel.
The object that acts as your panel delegate should conform to NSOpenSavePanelDelegate
.
Don't forget to set it via:
[panel setDelegate:self];
Detailed information about the NSOpenSavePanelDelegate protocol can be found in the docs.