How to make Cocoa document package type with it's extension hidden by default? -
I am creating a cacao application which uses a document package (bundle) because I have specified an extension And the searcher now recognizes the document as a document with extensions. But the extension of the folder is still displayed, and I want to hide it by default (like the application bundle) is there an alternative to doing this?
you -setAttributes: ofItemAtPath: error:
the method of NSFileManager
can set the file attributes of any file. In this situation, you want to set the value of the NSFileExtensionHidden
key.
To apply this to your saved document, you can cancel the -writeToURL: ofType: error:
in your NSDcast
subclass and more Then set the file extension to hide after the document is saved:
- writeToURL: (NSURL *) absoluteURL ofType: (NSString *) typeName error: (NSError **) Out Error {// to save the call file if (! [Super writeToURL: absoluteURL type: typeName error: outError]) do not return; // Get the path of the saved file NSString * filePath = [absoluteURL path]; // File extension hidden attribute in the name of the NSDictionary * fileAttrs = [Object with NSDictionary Dictionary: [NSNumber Number Vithubles: Yes] for: NSFileExtensionHard]; If (! [NSFileManager default manager] setAttributes: fileAttrs ofItemAtPath: filePath error: outError]) {return; } Yes return; }
Comments
Post a Comment