Reputation: 77
I am building a Non-Document-based cocoa app that I want to behave as follows:
In my app delegate, which currently handles the table view, I implemented the following method to open a new Item Window:
-(IBAction)newItem:(id)sender {
MyItemWindowController *itemController = [[MyItemWindowController alloc]initWithWindowNibName:@"MyItemWindowController"];
[itemController showWindow:self];
}
The window does show, but it disappears almost immediately. If however, I instantiate a Window Controller that is an instance variable of my appDelegate, the window does stick around, but obviously, only one such window can remain open at any given time.
I would really like to have the mentioned functionality, but do not want to use the Document-based architecture, as I don't need to be able to save items as documents to disk.
Any suggestions? I know I must be missing something really basic, but I just cannot figure it out!
Upvotes: 0
Views: 871
Reputation: 9392
I'm guessing your window disappeared because of ARC (not too familiar with it, so I'm not certain if that's the reason), so just do what you said, but instead of having a MyItemWindowController as your instance variable, have an array as your instance variable that adds a new window controller whenever you need another new window.
Upvotes: 4