In article <1ipufkt.15undtah98xufN%jim@magrathea.plus.com>,
jim.DeleteThis@magrathea.plus.com (Jim) wrote:
> I'm trying to understand how multi-window apps work, or more
> specifically windows attached to other objects than the main one.
>
> I've written a very small test app
> <http://www.ursaminorbeta.co.uk/test.zip> to demonstrate this (pretty
> sure I yanked the binaries - 2.3MB).
While I'm waiting for it to download, I'm going to guess you didn't.
There's no way a "very small" test app should have source/resources that
make a 2MB zip file. That dwarfs a large percentage of fully functional
released software.
Now downloaded and unzipped, I see the "build" folder is 5.5MB. You
yanked the binaries but not a whole bunch of build by-product.
> Now, I've whipped this up very quickly so I'm aware that's it's got
> problems in the memory management area, but I would still expect the
> second window to open when I press the button. It doesn't, so I'm making
> a fundamental mistake somewhere.
>
> I'd be very grateful if someone could explain it to me using small words
>
The secondObject you've created dynamically at runtime doesn't have
anything bound to its theWindow instance variable. I'm on a 10.4 machine
right now so I can't read XIB files without a lot of eyestrain, but I'm
guessing you instantiated a secondObject in that file and tied a window
instance to it and wondered why that's not working. The answer is that
the code that reacts to your button press doesn't use the XIB's
secondObject. It makes its own.
Solutions:
1. Give your firstObject an outlet that references a secondObject and
establish that relationship in the XIB. Then use the outlet in your
button: method.
2. Have your secondObject class, on initialization, create its own
window (or load one from the app resources).
--
"Harry?" Ron's voice was a mere whisper. "Do you smell something ... burning?"
- Harry Potter and the Odor of the Phoenix