Reading RTF files
Reading RTF files
- Subject: Reading RTF files
- From: Matt Ball <email@hidden>
- Date: Sat, 1 May 2004 19:57:54 -0400
I'm having a serious problem getting my program to read RTF files. I'm
following the tutorial located at
http://developer.apple.com/documentation/Cocoa/Conceptual/Documents/
Tasks/ImplementingDocApp.html
My MyDocument.h looks like this:
- (void)windowControllerDidLoadNib:(NSWindowController *) aController
{
[super windowControllerDidLoadNib:aController];
// Add any code here that needs to be executed once the
windowController has loaded the document's window.
[textView setAllowsUndo:YES];
if (fileContents != nil) {
[textView setString:fileContents];
[fileContents release];
fileContents = nil;
}
}
//------------------------------------------------------------------
- (NSData *)dataRepresentationOfType:(NSString *)aType
{
NSAssert([aType isEqualToString:@"rtf"], @"Unknown type");
return [textView RTFFromRange:NSMakeRange(0, [[textView
textStorage] length])];
}
// --------------------------------------------------------------------
- (BOOL)loadDataRepresentation:(NSData *)data ofType:(NSString *)aType
{
NSLog(@"Test", nil);
NSAssert([aType isEqualToString:@"rtf"], @"Unknown type");
fileContents = [data copyWithZone:[self zone]];
return YES;
}
Saving works fine; Any file i make will open fine with TextEdit.
However, when I try to open a file using my program, it just opens a
new window with the title of the document, but the textView in the
window is empty. The Run window says:
2004-05-01 19:56:54.458 Document[2582] *** -[NSPageData _isCString]:
selector not recognized
2004-05-01 19:56:54.466 Document[2582] *** -[NSPageData _isCString]:
selector not recognized
I've been trying to resolve this problem for several hours and I have
made no progress. Any help would be appreciated.
-- Matt Ball
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.