I'm probably missing something, but...
I'm probably missing something, but...
- Subject: I'm probably missing something, but...
- From: Simon Stapleton <email@hidden>
- Date: Fri, 3 Aug 2001 07:47:53 +0100
Hi.
I'm having a minor conceptual problem here - it's probably totally
obvious what I need to do, but here goes anyway.
My application is basically a graphical XML editor for powerkite
design. As a part of this, I need to be able to show (and edit at a low
level, but that comes later) curves of various types. My model objects
are well-defined and, thanks to Sen:te's rather wonderful OCUnit,
working, and I've slapped together some graphical test harness code
which enabled me to use ObjectAlloc pick up some nasty little (and
not-so-little) memory leaks. So far so good. The objects themselves
emit all the necessary notifications and are totally ready to be wrapped
up in the front end.
So. I need a general-purpose 'curve viewer' interface. Easy enough to
do - I create a .nib file with an 'OKCurveView' (custom subclass of
NSView) in it, this contains all the necessary drawing code, and all it
requires is access to the model objects (provided by its owner in an
NSArray). On initialisation, it looks for the model objects and hooks
up to the notifications, and away we go. Easy.
Except that this is a 'generic' interface, and can sit within multiple
windows (or, indeed, multiple times within the same window). Now I know
how to dynamically load the .nib, and how to strip out the view from an
offscreen panel and place it within my own window. The problem is that
I don't know beforehand what class the file's owner will be. And
without that, I can't get to the model objects. So I can't do it.
Do I really need to have separate (functionally almost identical) .nib
files for every possible place that I want to put the view? God, I hope
not.
I don't mind having to jump through a few programmatic hoops to do
this - everything else has been so simple it's frightening. It's about
time things got hard ;-) but I'd really rather keep single interfaces
wrapped up in single .nib files if I can.
Thanks for any advice or pointers as to where to look. You guys rock.
Simon