Re: Newbie Connections Question - Sorry!
Re: Newbie Connections Question - Sorry!
- Subject: Re: Newbie Connections Question - Sorry!
- From: Nate Murray <email@hidden>
- Date: Mon, 13 Sep 2004 19:36:00 -0700
...The other instances
you have created separately cannot be expected to know
about the AdamView....
have the AdamController
tell the sprites about itself and the AdamView.
This is exactly what I wanted to know. Now, how do I go about telling
the sprites about
the AdamView and AdamController, etc? Specifically the ones that have
already been
created by Interface Builders Nib file.
Because the way I have it set up now is that in the Nib an instance of
AdamSprite is created, but it doesnt do anything. Only the sprite that
is created by (lets say) AdamController is on the screen and moves. So
what I should probably do is delete AdamSprite from the nib completely
and have the AdamController make the only copy and tell the sprite
about itself and its friends created by the Nib.
Lets up the ante a little:
Not that I expect everyone else to write my code for me, but one of the
things Im specifically looking to do is access the [NSView bounds]
method. (ie [AdamView bounds])
I need to moveSprite method located in AdamSprite to know what the
bounds of my custom subclass of NSView (AdamView) are. So that way we
can keep the sprite on the screen.
Thanks for your help guys,
-Nate
On Sep 13, 2004, at 7:22 PM, Harilaos Skiadas wrote:
Nate,
Summary: How can my object instances access my IB
Outlets??
The Long Question:
okay im having a problem connecting my two classes.
I have three classes (among other things)
AdamView (my subclass of NSView)
AdamController
AdamSprite
The connections you have in interface builder are only
between the instances of your classes that you have in
your nib file. In other words, what happens when your
program loads the nib file is that it creates an
instance of AdamView, and instance of AdamController
and an instance of AdamSprite, and creates connections
between them as you have indicated in IB. But it only
creates on instance of AdamSprite. The other instances
you have created separately cannot be expected to know
about the AdamView.
My guess is that maybe what you want to do is have the
AdamController and the AdamView created in the NIB
file, but then have the AdamController
programmatically create as many instances of
AdamSprite as you need (maybe in an NSArray or
something like that), and then have the AdamController
tell the sprites about itself and the AdamView.
I have all the connections in interface builder set
up correctly. The
IB outlets are in my header files. AdamView, and
AdamController can
talk to each other and AdamSprite.
AdamSprite can even see the AdamView and
AdamController >sometimes.
For instance, when I debug and put a break in
AdamSprite->awakeFromNib
- (void)awakeFromNib
{
NSLog(@"[AdamSpritesController awakeFromNib]");
break-> [adamView anything];
}
under Arguments->self->adamView i get a perfectly
good >connection
"value" (0x53bf50)
The problem lies when I try to access adamView (or
any other >IBOutlet)
from the object that is created by something other
than the nib.
Let me re-phrase that: I have more than one
AdamSprite object. One >for
each sprite on the screen plus the one that the Nib
file creates when
the program starts.
The AdamSprite object that the Nib file creates seems
to have access >to
all the IBOutlets but any other instances i create
have a "adamView"
value of 0x0. Shouldnt all my instances have access
to all of the IB
Outlets? If not, how to I give it to them?
I know this is a basic question but Ive spent a while
looking it up in
the documentation and various tutorial sites
(orielly, cocoa dev
central, etc). But I still cant figure it out!
Im assuming from what little I know of Objective-C
that someone is
going to tell me that I need to have a (Controller?)
class as an
intermediary between my instance objects and the
class. Now if I >could
just figure out how to do this...
What you want is not a controller class, you want an
instance of a controller class. A class just describes
what abilities your controller should have, but only
the individual instances have these properties, as far
as I understand. A class is just a blueprint that you
can use to create instances of it. That's what you do
in IB every time you drag something from the pallete
to the window.
Any help would be appreciated and I could certainly
post the project >if
anyone was that interested in helping.
Thanks,
-Nate
I hope this makes some sense. Good luck! The beginning
is always hard, but cocoa and objective-c are really
fun to work with, and this list is generally very
helpful.
Btw, some other good sources of answers are the
cocoadev wiki
http://www.cocoadev.com
and http://www.stepwise.com
Haris
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
_______________________________________________
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