🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.sys.next.programmer
3 messages
3 total messages Started by bill Wed, 29 Jul 1992 18:45
Need help with multiple nib file programming...
#318
Author: bill
Date: Wed, 29 Jul 1992 18:45
9 lines
668 bytes
I have several modules (a nib for each module) and would like for one  
module to talk to another but I can not connect the modules together via  
IB with the control drag mouse routine.  

How do I have the modules communicate with each other?  

Thanks in advance.

		Bill
Re: Need help with multiple nib file programming...
#406
Author: Gregory H. Anderson
Date: Sat, 01 Aug 1992 19:58
40 lines
1667 bytes
In article <1992Jul29.184519.22474@aio.jsc.nasa.gov>  
bill@epnxt.jsc.nasa.gov writes:
> I have several modules (a nib for each module) and would like for one  
> module to talk to another but I can not connect the modules together via  
> IB with the control drag mouse routine.  
> 
> How do I have the modules communicate with each other?  
> 
> Thanks in advance.
> 
> 		Bill

Connections cannot be maintained between NIB files, which is why you can't  
control-drag. There is simply nothing to resolve to at load-time.

You have to do it through the app (your own subclass) or the app's  
delegate (your own delegate), either of which needs an instance variable  
for the pieces that need to intercommunicate. Then each instance variable  
needs a method that simply returns the object's ID. For example:

@interface AppDelegate
{
	id object1;
	id object2;
}
- object1;
- object2;
@end

Then in code you say
#import AppDelegate.h
....
	[[[NXApp delegate] object1] doSomeMethod:sender];
....

--
Gregory H. Anderson          | "We're very tolerant around here,
Benevolent Dictator-for-Life |  being only amateurs ourselves."
Anderson Financial Systems   | - Tortoise (Godel, Escher, Bach)
greg@afs.com  (Nextmail OK)  | 
Re: Need help with multiple nib file programming...
#428
Author: Andrew Loewenstern
Date: Mon, 03 Aug 1992 17:53
63 lines
2460 bytes
In article <1992Aug1.195812.831@afs.com> greg@afs.com writes:
>You have to do it through the app (your own subclass) or the app's  
>delegate (your own delegate), either of which needs an instance variable  
>for the pieces that need to intercommunicate. Then each instance variable  
>needs a method that simply returns the object's ID. For example:
>
>@interface AppDelegate
>{
>	id object1;
>	id object2;
>}
>- object1;
>- object2;
>@end
>
>Then in code you say
>#import AppDelegate.h
>....
>	[[[NXApp delegate] object1] doSomeMethod:sender];
>....

What I do (fairly often I might add...) is add a +new method to an
object that will be needed all over the application.  This only works
if you want to have a single instance of this object in the app (like
specific controllers and such...).  Add a method like this to your
class (but don't put it in the header file...):


static id myself		/* the one instance of this class */

+ new
{
  if(!myself)
      myself = self = [super new]; /* put additional initialization in */
				   /* the -init method. */
  else
    self = myself;
  
  return self;
}


When you need this object, just call [MyClass new].  If the object
does not exist yet, it will be created (be lazy...), if it already
exists, then it will just give you back it's id.

Now for messaging between nibs, put this in the file's owner class for
the nib with the loading code in the init method and put the object1,
object2, etc... methods in the nib's owner instead of cluttering up
the app delegate (which is usually too cluttered up as it is...).

So instead of [[[NXApp delegate] object1] doSomeMethod:sender]; you
will do [[[MyNibOwner new] object1] doSomeMethod:sender];.

The +new method is useful for a lot of situations, and the above just
helps organize things.


andrew
-- 
andrew@cubetech.com
Andrew Loewenstern      | "Remember what the doormouse said...
Cube Technologies, Inc. |  Feed your head."  - Jefferson Airplane
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads