Re: Please help?...
Re: Please help?...
- Subject: Re: Please help?...
- From: Albert Atkinson <email@hidden>
- Date: Fri, 22 Feb 2002 08:00:58 -0500
Hmm,
I just added the following windowControllerDidLoadNib: code:
- (void)windowControllerDidLoadNib:(NSWindowController *) aController;
{
[super windowControllerDidLoadNib:aController];
if (fileContents)
{
[textView setString:fileContents];
[fileContents release];
fileContents = nil;
}
}
Now when I build my app it gives me a warning:
warning: passing arg 1 of 'setString:' from incompatible pointer type
It builds it and runs it and when I choose the RTF file it gives me this
error:
2002-02-22 06:44:49.421 PowerText[3493] *** Assertion failure in
-[Document loadDataRepresentation:ofType:], Document.m:31
2002-02-22 06:44:49.448 PowerText[3493] Unknown type
Also, this did not happen before I added the code but if I close the
last window and switch to a different application and then switch back
it will crash and say:
PowerText.app has exited due to signal 10 (SIGBUS).
This also happens if I close the last document window and try to open
something again.
Any suggestions?
Thanks!
Albert
On Friday, February 22, 2002, at 01:49 AM, Scott Anguish wrote:
are you sure this isn't working?
part of the problem is that you're not actually doing anything with the
fileContents by the looks of things.. that's something that is usually
handled in the windowControllerDidLoadNib:.. and you're not calling
super there either.. which may be an issue at some point...)
so nothing is going to happen in your UI.. you just have a variable
(fileContents) set with the data..
- (void)windowControllerDidLoadNib:(NSWindowController *) aController;
{
[super windowControllerDidLoadNib:aController];
if (fileContents)
{
[theTextView setString:fileContents];
[fileContents release];
fileContents = nil;
}
}
also, you really don't need to copyWithZone:.. you could just retain
the data if you wanted to (and Zones are sort of unnecessary for most
apps according to general scuttlebutt)
On Thursday, February 21, 2002, at 09:23 PM, Albert Atkinson wrote:
Hello!
I am trying to implement a simple saving and loading of rtf files in my
app. I have the following code in my "Document.m" file:
#import "Document.h"
@implementation Document
- (NSString *)windowNibName
{
return @"Document";
}
- (void)windowControllerDidLoadNib:(NSWindowController *) aController
{
}
- (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 {
NSAssert([aType isEqualToString:@"rtf"], @"Unknown type");
fileContents = [data copyWithZone:[self zone]];
return YES;
}
@end
I must be doing something wrong because this does not work. Any
suggestions?
Thanks!
Albert
_______________________________________________
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.
_______________________________________________
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.
_______________________________________________
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.