🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.next.programmer
Article #1135

Re: lots of objects to display

#1135
From: Robert D. Nicholson
Date: Fri, 14 Aug 1992 07:02
54 lines
2300 bytes
woo@ornl.gov(John W. Wooten) writes:

>I have an app in which I have a lot of elements, which may have
>many different geometrical shapes, but are subclassed from a general  
>element object which is a subclass of View.  As I build them, they are  
>stored in a list.

>I want them to be drawn in a View (myView) in myWindow.  Each element   
>subclass has a drawSelf method and each instance has it, of course.

>When my controller does a [myView display], the background appears, but  
>does each element have to be individually sent a [myElement drawSelf]?
>It then seems that they each have to be a subView of the original View.

>Somehow it should be simpler than this, so I think I'm missing  
>something.



>--
>-----------------
>J. W. Wooten

Well, {myView display] will only send display to myView and myView's subviews
which have been set up via view's addSubview.  Thus you should create a 
allGraphicsPerform method  and have it send a display to each element in the list.
Actually you can pass the method you wish to have executed as a parameter and
thus generalise even further.

Check out Summer NeXTWORLD , 1992 in Charles L. Perkins Article on Composition
makeSquaresPerform:

The code looks like 

- makeSquaresPerform:(SEL) aMessage {
return [[self viewList] makeObjectsPerform:aMessage];
}

If you wish to set up something that uses parameter passing. then you 
could try this.

- makeSquaresPerform:(SEL) aMessage with: anObject {
return [[self viewList] makeObjectsPerform:aMessage with: anObject];
}

Basically its makes use of behaviour already in List. 

replace [self viewList] with your list's reference or method
to retrieve its reference.

Hope this helps.

This code assumes that all your objects will perform "aMessage" perhaps
it might be worthwhile to check using Object's respondsTo: first.
Technical Details
Message-ID: <1992Aug14.070249.13214@monu6.cc.monash.edu.au>
Path: arc1-ca.pugleaf.net!sparky!uunet!munnari.oz.au!bruce.cs.monash.edu.au!monu6!ede978e
References: <1992Aug13.204505.26009@ornl.gov>

Show Full Headers
Complete Article Headers
Newsgroups: comp.sys.next.programmer
Path: arc1-ca.pugleaf.net!sparky!uunet!munnari.oz.au!bruce.cs.monash.edu.au!monu6!ede978e
From: ede978e@monu6.cc.monash.edu.au (Robert D. Nicholson)
Subject: Re: lots of objects to display
Message-ID: <1992Aug14.070249.13214@monu6.cc.monash.edu.au>
Organization: Monash University, Caulfield Campus
References: <1992Aug13.204505.26009@ornl.gov>
Date: Fri, 14 Aug 1992 07:02:49 GMT
Lines: 54