I am working on a basic hello world application that will open a txt document, edit it and then finally save the document. What is the best practice for handling the edit.
I have read Apple's documentation throughly, but when I check for the NSError **outError
the method returns NO
. When I comment it out
- (BOOL)writeToURL:(NSURL*)writeURL
ofType:(NSString*)type
forSaveOperation:(NSSaveOperationType)saveOp
originalContentsURL:(NSURL*)origURL
error:(NSError**)errorPtr
will write out the file.
Is there a best practice for saving a document? Is there something wrong with the below implementation? If you comment out the check for errorPtr then the modify file is written to original file.
- (BOOL)writeToURL:(NSURL*)writeURL
ofType:(NSString*)type
forSaveOperation:(NSSaveOperationType)saveOp
originalContentsURL:(NSURL*)origURL
error:(NSError**)errorPtr {
if (errorPtr) {
*errorPtr = [NSError errorWithDomain:NSOSStatusErrorDomain code:unimpErr userInfo:NULL];
return NO;
}
return [[[self.txtView textStorage] string] writeToURL:writeURL atomically:NO encoding:NSUTF8StringEncoding error:errorPtr];
}