cocoa - Problem with NSDocument and writeToURL:ofType:error: -


I am working on a document-based application, and I want to use the document package as my file format I am To do this, it seems that the NSDcast method needs to be overridden. I> -writeToURL: ofType: error: .

It sometimes works, but under some conditions, for example, this code works:

  - (BOOL) writeToURL: (NSURL * ) Type of absoluteURL: (NSString *) type name error: (NSError **) outError {NSFileWrapper * wrapper = [[NSFileWrapper alloc] initDirectoryWithFileWrappers: zero]; [Rapper Adrenal Filipino Content: [Please "Datujing encoding: NSUFF 8 string encoding] work" Favorite Filename: @ "Fobour"]; [Wrapper writeToURL: absoluteURL Option: NSFileWrapperWritingAtomic originalContentsURL: Zero Error: outError]; NSDictionary * Metadata = [object with NSDictionary dictionary: @ "0.1" forKey: @ "version"]; NSURL * mdURL = [NSUr File URL Thath Path: [[Absolute Colonel Path] Stringbapping Path Companent: @ "SiteInfo.Plist"]]; [Metadata writeout URL: atomically mdURL: yes]; Yes come back }  

However, this is not a code (it is similar to the above, but the NSFileWrapper bit has been extracted):

  - (BOOL) writeToURL: ( NS URL *) absoluteURL type: (NSString *) type name error: (NSError **) outError {NSDictionary * Metadata = [Object with NSDictionary dictionary: @ "0.1" forKey: @ "version"]; NSURL * mdURL = [NSUr File URL Thath Path: [[Absolute Colonel Path] Stringbapping Path Companent: @ "SiteInfo.Plist"]]; [Metadata writeout URL: atomically mdURL: yes]; Yes come back }  

The above code puts this secret error in the console ("lithograph" is the name of my app, and ".site" is the package extension):

 < Can not remove temporary item in Code> NSDcast file: // local host / private / var / folders / qX / qXL705byGmC9LN8FpiVjgk +++ TI / temporary item / (A% 20 document% 20 20% to 20% saved% 20 % 20 Lithograph% 207) / Untitled% 20Site.site. Here's the error: error domain = NScOOR command code = 4UserInfo = 0x10059d160 "" Untitled SiteSite "could not be deleted." 

> "post-text" itemprop = "text">

If you are creating a file wrapper from your document, then you instead of -writeToURL - FileWrapperOfType: error: should use: OfType: error: .

You will create a file wrapper for the Info.plist file, put it in the Folder file wrapper and then return to the folder wrapper:

  - (NSFileWrapper *) fileWrapperOfType: ( NSString *) typeName Error: (NSError **) Out Error {NSFileWrapper * wrapper = [[[NSFileWrapper alloc] initDirectoryWithFileWrappers: Zero] Autorescope]; [Rapper Adrenal Filipino Content: [Please "Datujing encoding: NSUFF 8 string encoding] work" Favorite Filename: @ "Fobour"]; NSDictionary * Metadata = [object with NSDictionary dictionary: @ "0.1" forKey: @ "version"]; NSString * errorDescription = Zero; NSData * dictionaryData = [NSPropertyListSerialization dataFromPropertyList: Metadata Format: NSPropertyListBinaryFormat_v1_0 ErrorDiscovery: & amp; ErrorDescription]; If (! Dictionary data) {if (! Error description) error description = @ "unknown error"; If (Out Error) * Out Error = [Damn with NSError Error: @ "YourErrorDomain" Code: 69 User Information: [NSDictionary Dictionary with Object: Error for: NSLocalizedDescriptionKey]]; Return zero; } [Cover AdraguerFileWindowsContent: DictionaryData FavoritesFilename: @ "Info.Plist"]; Return cover; }  

Comments

Popular posts from this blog

MySql variables and php -

url rewriting - How to implement the returnurl like SO in PHP? -

Which Python client library should I use for CouchdB? -