🚀 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 Ron Pomeroy x(Coop) Thu, 06 Aug 1992 00:09
Using nibs
#465
Author: Ron Pomeroy x(Coop)
Date: Thu, 06 Aug 1992 00:09
45 lines
1625 bytes
Hello netters,

I'm still fairly new to the appkit so bear with me.

In the example WhatADrag/Controller.m we have the following method:

- displayInfoPanel:sender
{
    if (!infoPanel) {
      [NXApp loadNibSection:"InfoPanel.nib" owner:self];
    }
    [infoPanel makeKeyAndOrderFront:NULL];
    
    return self;
}

suppose I don't check to see if infoPanel exists:

- displayInfoPanel:sender
{
//    if (!infoPanel) {
      [NXApp loadNibSection:"InfoPanel.nib" owner:self];
//    }
    [infoPanel makeKeyAndOrderFront:NULL];
    
    return self;
}

Now when I hit the Info button in the menu (in the compiled app),  
displayInfoPanel:sender is sent and the nib is unarchived again and again.  

My question is - do all of the instances have the same id (i.e. "infoPanel) ?  

What I would like to be able to do is compose an object in interface builder,  
save it as a nib,  dynamically (programatically) create copies of that nib, but  
each with a unique id.  Kinda' like using a nib for a class definition.  Is  
this possible?
 

--
Ronald Pomeroy
Advanced Micro Devices
CAM Applications Group
Austin, Texas
rpomeroy@aunext3.amd.com
Re: Using nibs
#506
Author: moose
Date: Fri, 07 Aug 1992 17:36
46 lines
1817 bytes
In article <1992Aug6.000907.1895@dvorak.amd.com> rpomeroy@aunext3.cam.amd.com  
(Ron Pomeroy x(Coop)) writes:
> Hello netters,
> 
> I'm still fairly new to the appkit so bear with me.
> 
> suppose I don't check to see if infoPanel exists:
> 
> - displayInfoPanel:sender
> {
> //    if (!infoPanel) {
>       [NXApp loadNibSection:"InfoPanel.nib" owner:self];
> //    }
>     [infoPanel makeKeyAndOrderFront:NULL];
>     
>     return self;
> }
> 
> Now when I hit the Info button in the menu (in the compiled app),  
> displayInfoPanel:sender is sent and the nib is unarchived again and again.  
> 
> My question is - do all of the instances have the same id (i.e. "infoPanel) ? 

Yes, and you have a huge memory leak.  infoPanel will always point to the last  
info panel loaded, clobering your pointers to the other infoPanels.  Now, if  
you create an object with several id's, then have some code like this

- displayWindow:sender
{
	id	aNewObject;

	[myList addObject:(aNewObject = [[ANewObject alloc] init])];
       	[NXApp loadNibSection:"InfoPanel.nib" owner:aNewObject];
	return self;
}

Then each object would have their id's maintained, and by walking myList you  
can get to all the windows you have loaded/created.
	
 

--
Michael Rutman			|	moose@svcdudes.com
Cubist				|	makes me a NeXT programmer
Software Ventures		|	maker of MicroPhone II
#include <std.disclaimer>
Re: Using nibs
#508
Author: Andrew Loewenstern
Date: Sat, 08 Aug 1992 06:13
27 lines
1611 bytes
In article <1992Aug6.000907.1895@dvorak.amd.com> rpomeroy@aunext3.cam.amd.com writes:
>Now when I hit the Info button in the menu (in the compiled app),  
>displayInfoPanel:sender is sent and the nib is unarchived again and again.  
>
>My question is - do all of the instances have the same id (i.e. "infoPanel) ?
>
>What I would like to be able to do is compose an object in interface builder,
>save it as a nib,  dynamically (programatically) create copies of that nib, but  
>each with a unique id.  Kinda' like using a nib for a class definition.  Is  
>this possible?

all ID's are unique.  It's not possible to have two separate objects
in the same application that have the same ID.  When you repeatedly
load a nib, you are creating the same objects, but they are all
separate and distinct.

For instance, if you had a nib that was a document window, you would
sinmply load the nib each time you needed a new doc window.

so yes.

andrew
-- 
andrew@cubetech.com     | "We shall not cease from exploration
Andrew Loewenstern      |  And the end of our exploring
Cube Technologies, Inc. |  Will be to arrive where we started
                        |  And know the place for the first time." -T.S. Eliot
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