Im trying to implement a save feature to save an html file. Currently it returns errors when I try and save. My code is
- (BOOL)writeToURL:(NSURL *)absoluteURL ofType:(NSString *)typeName error:(NSError **)outError
{
NSData *saveData = [[[editorView textStorage] string] dataUsingEncoding:NSUTF8StringEncoding];
[saveData writeToURL:absoluteURL ofType:typeName error:outError];
if ( outError != NULL ) {
*outError = [NSError errorWithDomain:NSOSStatusErrorDomain code:unimpErr userInfo:NULL];
}
else {
return YES;
}
}
When I try and save it returns the errors: -[NSConcreteMutableData writeToURL:ofType:error:]: unrecognized selector sent to instance 0x10016d900. I tired using a plain NSString and that didn’t work either.
-[NSConcreteMutableData writeToURL:ofType:error:]: unrecognized selector sent to instance 0x10016d900
Thanks for any help
That’s because an NSMutableData doesn’t respond to that message. Only documents respond to that message.
You need to send your data object a message it does respond to, such as
writeToURL:options:error:.