Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: fundamental question: how do I call controller methods from other classes?




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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden

References: 
 >fundamental question: how do I call controller methods from other classes? (From: Johnny Lundy <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.