I'm writing a Mac OS app in Objective-C. The mainWindowController has a vertical NSSplitView in the application's window. This split view is in the mainWindowController's nib file. In mainWindowController's viewDidLoad, I instantiate two child controllers--call them A and B. A and B each have their own nib that contains nothing but an NSView. Later, A and B will instantiate children objects in their own viewDidLoad, giving a hierarchy.
As you may expect, A's view and B's view form the left and right panes of the mainWindowController's split view. Herein lies the problem.
When I instantiate each object in mainWindowController, I don't know if their views actually exist after the alloc/init call. In fact, I believe I should assume they do not yet exist. mainWindowController must add A and B to its split view and then create the autolayout constraints for both A and B, since they are relative to each other.
So, in mainWindowController, how can I know when A and B have loaded their views so that I can add them to the split view and setup the proper autolayout constraints? I can think of some ways to implement this, but each solution is uglier than the last. What is the best practice here?
As I mentioned, A and B will be creating their own subviews, etc, so this is a general problem I will have to deal with in this app.
I appreciate any input!
As you may expect, A's view and B's view form the left and right panes of the mainWindowController's split view. Herein lies the problem.
When I instantiate each object in mainWindowController, I don't know if their views actually exist after the alloc/init call. In fact, I believe I should assume they do not yet exist. mainWindowController must add A and B to its split view and then create the autolayout constraints for both A and B, since they are relative to each other.
So, in mainWindowController, how can I know when A and B have loaded their views so that I can add them to the split view and setup the proper autolayout constraints? I can think of some ways to implement this, but each solution is uglier than the last. What is the best practice here?
As I mentioned, A and B will be creating their own subviews, etc, so this is a general problem I will have to deal with in this app.
I appreciate any input!
I do think it is loaded when initWithNibName returns.when [[alloc] initWithNibName] returned, it was not guaranteed that those nibs would be loaded
As for avoiding an extra view, I do not see this as a problem. There are so many objects allocated by the system, that even if you have hundreds of view, just an extra view each time will not make a difference.
There are probably many other places in code more important top focus on if you need to optimize.
In anycase, good to read it works.
You should close the thread now.