Opening and NSCoding an NSObject Subclass
Opening and NSCoding an NSObject Subclass
- Subject: Opening and NSCoding an NSObject Subclass
- From: Ronnie O <email@hidden>
- Date: Thu, 28 Jul 2005 14:24:54 -0500
I have an NSObject subclass that implemements NSCoding. I can
successfully save a file by archiving the subclass as root object with
the following line:
NSData *projData = [NSArchiver archivedDataWithRootObject:self]
//self is of class type MyClass
I open the file using NSUnarchiver::
NSData *projData = [[NSData alloc] initWithContentsOfFile:filename];
MyClass *openedFile = [NSUnarchiver unarchiveObjectWithData:projData];
[openedFile prepOpenedFile]; // I call a method in the newly created
MyClass instance
The prepOpenedFile method does respond and I can see that the method
call is being received. I also load a nib in the prepOpenedFile
method:
[NSBundle loadNibNamed:@"MyWindow.nib" owner:self];
I can also set the title in this method call with:
[[self projMainWindow] setTitleWithRepresentedFilename:[self filePath];
This all works fine when I open a new file. But when I attempt to use
the menu actions that are hooked up to the mainMenu.nib, I am not
getting actions performed on my window like I normally do when I open
a "new" file. I tried [[self projMainWindow] makeFirstResponder] to
ensure the window is part of the responder chain and no luck. I know
the window is being recognized because I can set the title
succesfully. I tried [[self projMainWindow] setDelegate:self] to
ensure it is part of the responder chain, which should be connected as
part of the nib anyways, and no luck. The menu action is calling the
"actionTo WIndow" method successfully but the window is not receiving
the results of the action. I also tried [myView reloadData] and got
nothing. Any ideas on why the window is not receiving word of my menu
action method calls? I am initially worried my problem is either my
NSCoding method as written above or somehting to do with the fact I am
working with a subclass. Any ideas?
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden