Exactly. What you want to do is, from the appropriate
place in AdamController, have something like
AdamSprite *mySprite;
mySprite = [[AdamSprite alloc] init];
This will create an instance of AdamSprite called
mySprite, and your AdamController knows about it.
Actually, you first need to tell your AdamController
about the AdamSprite class by adidng #include
"AdamSprite.h" at the beginning of AdamController.m
You might want to write your own init method to
initialize the special variables that AdamSprite might
have. Now, whenever you want mySprite to do something,
all you have to do is call the appropriate method by
something like
[mySprite doCoolStuff];
if you want it to know about the view the controller
knows about, which I will call myView, I think you
could do (not entirely sure about this) something
like:
[mySprite doCoolStuffWithView:myView];
and then you will have access to myView within the
method doCoolStuffWithView: of AdamSprite (which of
course you should implement).
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.
well, once it knows about the view, it can learn
anything about the view too, with [myView bounds].
the one thing to keep in mind when calling these
methods, is that you always have to call them for the
instances of a class. They are instance methods, not
class methods. alloc is a class method, so [AdamClass
alloc] creates a new instance of AdamClass and returns
it, so with something like
myAdamClassInstance = [AdamClass alloc];
myAdamClassInstance now points to a newly created
instance of class AdamClass. Then you would usually
need to further initialize it to set initial values to
variables etc, which would be done with something like
[myAdamClassInstance init];
init is an instance method.
Then you are responsible for these instances, and you
should release them when you are done.
I can tell you more about this off the list, it would
probably bore most of the list members.
Indeed this is very basic stuff, I would recommend you
get your hands on some of the excellent books on
Objective-C and Cocoa programming that are out there
and dig in. My personal favorites, and generally
considered among the best I think, are Stephen
Kolchan's "Programming in Objective-C" and Aaron
Hillegass' "Cocoa programming for Mac OS X". The first
one teaches you about classes and instances, and
object-oriented programming in general, assuming
little or no knowledge, while the second shows you how
to use the tools in cocoa, and how to work with XCode
and IB. IMHO they are both must-haves, especially for
newbies.
my 2 cents
Thanks for your help guys,
-Nate
Haris
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com