Loading unknown object from NIB
Loading unknown object from NIB
- Subject: Loading unknown object from NIB
- From: Neil Baylis <email@hidden>
- Date: Tue, 11 Oct 2005 10:07:27 -0700
Is there a way to instantiate an object from a NIB without knowing at
compile time what class the object belongs to?
I have multiple such objects, each of which inherits from
NSWindowController. Each has its own nib. Each represents a slightly
different real world device with controls and indicators. These devices are
attached to an RS485 network. As they are discovered, I want to bring up a
window that's specific to the kind of device I discover. If I discover more
than one of the same device type, then I'll instantiate that nib multiple
times. Each device has a serial number to distinguish it from others of the
same type.
In the multiple nib example code, the main window controller imports the
interface of the second window controller. I can do this, but it means that
my application controller needs to import the interfaces for all the
different device types. And at runtime, if have code that looks at the
discovered device type, and then loads the nib for that device. It works,
but it's ugly, and creates lots of extra dependencies in my code. It also
means whenever I add a new device type, I need to modify my application
controller to add a new case.
What I want to do to add a new device type to my network is just to add a
new nib, and create the new class. But I can't figure out how to set the
owner unless I know the class at compile time. If I make the owner
NSWindowController, then it doesn't find the methods that the subclass in
the nib implements.
At runtime, I can compute the name of the nib I need to load based on the
device type that I dynamically discover.
Can someone point me in the right direction?
Thanks,
Neil Baylis
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden