objective c - How to update an NSFileWrapper? -


i have nsfilewrapper content. want save (writetourl...:), add new content , save again.

i avoid writing again , again same files. so, if understood clearly, means option nsfilewrapperwritingatomic not me. save file wrapper in method

- (bool)writeadditionalcontent:(id)content                          tourl:(nsurl *)absoluteurl            originalcontentsurl:(nsurl *)absoluteoriginalcontentsurl                          error:(nserror *__autoreleasing *)error 

(of osx analogue of uimanageddocument)

and apple says "don't use option in override of -[nsdocument writetourl:oftype:error:]".

so, don't use option, updating files file wrapper (i mean : saving again) fails (see below). idea/clue ?


here :

1

i save first time

[self.filewrapper writetourl:[absoluteurl urlbyappendingpathcomponent:@"attached_files/"]                      options:0          originalcontentsurl:[absoluteoriginalcontentsurl urlbyappendingpathcomponent:@"attached_files/"]                        error:error] ; 

it works well.

my file wrapper

    /*      initializing file wrapper      */     _filewrapper = [[nsfilewrapper alloc] initdirectorywithfilewrappers:nil] ;     [_filewrapper setfilename:@"attached_files"] ;     [_filewrapper setpreferredfilename:@"attached_files"] ; 

2

i save second time same command. error

 error domain=nscocoaerrordomain code=516 "the file exists".  

the given name "attached_files".

3

if use option nsfilewrapperwritingwithnameupdating, still same error.

4

if use option nsfilewrapperwritingatomic, don't errors.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -