Re: Loading unknown object from NIB
Re: Loading unknown object from NIB
- Subject: Re: Loading unknown object from NIB
- From: Yann Bizeul <email@hidden>
- Date: Wed, 12 Oct 2005 00:56:48 +0200
Perhaps you should consider working with bundles instead of nibs.
Bundles can contain resources, so nib files.
You bundle's main class should conform a pre-defined protocol, so
that you can call common methods to determine specific informations.
This tutorial does have very good informations about plugins with
Cocoa :
http://cocoadevcentral.com/articles/000068.php
Yann Bizeul • yann at tynsoe.org
Cocoa Developer
Tynsoe Projects
BuddyPop • GeekTool • SSH Tunnel Manager • ...
http://projects.tynsoe.org/
Le 11 oct. 05 à 19:07, Neil Baylis a écrit :
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
_______________________________________________
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