Re: fundamental question: how do I call controller methods from other classes?
Re: fundamental question: how do I call controller methods from other classes?
- Subject: Re: fundamental question: how do I call controller methods from other classes?
- From: Jens Alfke <email@hidden>
- Date: Wed, 21 May 2008 23:51:30 -0700
On 21 May '08, at 9:42 PM, Johnny Lundy wrote:
I still don't know how to call one class from another (the reason I
always only have one class in my projects)
Yow! That's kind of a fundamental issue. Sort of like "I still don't
know how knights move, so I just leave them where they started." I
don't mean that to make fun; but rather to stress that you should
really take a look at the various example Cocoa apps in /Developer/
Examples and online, and study them to see how they do things. (The
very simple ones may only have one class, but the larger ones have
several.)
You're not going to be able to get beyond trivial apps without being
able to coordinate multiple classes. Really. Almost any serious
application has dozens or hundreds of custom classes in it.
If both objects are in the nib, make an outlet in one and wire it to
the other.
If one object creates the other, remember that pointer in an instance
variable.
If the created object needs to call back to the one that created it,
the creator could pass itself as a parameter to the created object's
init method, or call a setter afterwards; but often, if the created
object is part of the data model, it shouldn't know or care who
created it. Instead the controller object should observe notifications.
—Jens
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden