Hi,
Somewhere on my code I need to create several windows from a main window, each functioning with a specific configuration but all instances of the same controller object.
I also need to keep a list of open windows, so whenever I open a window I store its instance in a dictionary and when the window is closed I send a notification to the main window which fires a method that then removes that specific window from the dictionary.
I create windows by creating an instance of their controller object and then calling [showWindow:self] on it. I then store the window in the dictionary and exit the method.
My problem is that I'm neither releasing nor autoreleasing the newly created object as that should be done when the window is removed from the dictionary (right?). If I do release or autorelease that object, after I store it in the dictionary, I will get all sorts of errors when I try to remove the object from the dictionary.
1) Could this be a simple bug in Xcode that doesn't notice the instance being stored in the dictionary?
2) Anyway, why does autorelease destroy my window, if the dictionary is storing a reference to it?
[Update] Code below
CHPostgreSQLMainController *pgMainController = [[CHPostgreSQLMainController alloc]initWithConnectionSettings:(CHPostgreSQLSettingsModel *)entityFromArray error:&error];
// Only display the window if the connection was successful.
if (pgMainController) {
[pgMainController showWindow:self];
// Register the window we've opened on the list of open windows
[listOpenWindows setObject:pgMainController forKey:[entityFromArray connectionName]];
} else {
//call NSAlert
}