Saving a file when using NSDocument?

Apple answered this for you a very long time ago.

Thanks, I'll take a look at it – WTP Dec 31 '09 at 17:56.

I'd like to add that the example implementation of dataForType:error: in the linked page has some either outdated or flatly inaccurate information. Here is the report I sent to Apple: The example implementation of dataOfType:error: reads: - (NSData *)dataOfType:(NSString *)typeName error:(NSError **)outError { textView breakUndoCoalescing; NSData *data = textView dataFromRange:NSMakeRange(0, textView textStorage length) documentAttributes:nil error:outError; if (!data && outError) { *outError = NSError errorWithDomain:NSCocoaErrorDomain code:NSFileWriteUnknownError userInfo:nil; } return data; } There are a few problems with this. First, NSTextView does not have a dataFromRange:documentAttributes:error: method.

This should be text dataFromRange… given the assumed structure of the data specified in the document. Second, according to the documentation for NSAttributedString, dataFromRange:documentAttributes:error: "requires a document attributes dictionary dict specifying at least the NSDocumentTypeDocumentAttribute to determine the format to write. " So, the example implementation should read at least - (NSData *)dataOfType:(NSString *)typeName error:(NSError **)outError { textView breakUndoCoalescing; NSData *data = text dataFromRange:NSMakeRange(0, textView textStorage length) documentAttributes:NSDictionary dictionaryWithObjectsAndKeys:NSPlainTextDocumentType, NSDocumentTypeDocumentAttribute, nil error:outError; if (!data && outError) { *outError = NSError errorWithDomain:NSCocoaErrorDomain code:NSFileWriteUnknownError userInfo:nil; } return data; } or some other appropriate dictionary values for RTF or other text value types.

While it appears that the OP may not have seen that doc at the time of posting, simply linking to the doc doesn't help as much as one might think since the documentation is broken. I discovered this after quite some time banging my own head against the same error as the OP even though I had copied Apple's implementation verbatim. Hope this helps someone else.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions