NSDocument not loading nib soon enough
NSDocument not loading nib soon enough
- Subject: NSDocument not loading nib soon enough
- From: "Alan Smith" <email@hidden>
- Date: Wed, 21 Mar 2007 15:38:47 -0500
Hello,
I'm writing a NSDocument subclass and everything was going smoothly
until I tried to add file reading and writing. I spent quite some time
messing with it until I realized that my textView was not yet
connected to anything. So, I've stuck a log message in
windowControllerDidLoadNib and that appears in the output *after* my
document tried to load the file from disk. Below is some sample output
and below that is the loading method. (I know it has been
NSDeprecated, I want 10.3 support if possible.)
The question is, how do I get the nib to load so I can use my
IBOutlets when loading a file?
All help is greatly appreciated.
Peace, Alan
{
Opening file of type rtf
textView = (null)
windowControllerDidLoadNib:
}
- (BOOL)loadDataRepresentation:(NSData*)data ofType:(NSString*)type
{
NSLog(@"Opening file of type %@", type);
NSLog(@"textView = %@", textView);
if ([type isEqualToString: @"rtfd"])
{
[textView replaceCharactersInRange: NSMakeRange(0, [[textView
string] length]) withRTFD: data];
}
else if ([type isEqualToString: @"rtf"])
{
[textView replaceCharactersInRange: NSMakeRange(0, [[textView
string] length]) withRTF: data];
}
else
{
NSString *fileContents = [[NSString alloc] initWithData: data
encoding: NSMacOSRomanStringEncoding];
[textView setString: fileContents];
[fileContents release];
}
return YES;
}
--
// Quotes from yours truly -------------------------
"You don't forget, you just don't remember."
"Maturity resides in the mind."
"Silence is the Universe's greatest gift."
"When the World realizes that religion really is unnecessary, then it
shall evolve."
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden