• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: fundamental question: how do I call controller methods from other classes?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

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

  • Prev by Date: Re: creating a resource fork and writing raw bytes to it
  • Next by Date: Re: fundamental question: how do I call controller methods from other classes?
  • Previous by thread: Re: fundamental question: how do I call controller methods from other classes?
  • Next by thread: ObjC Question - labeled arguments
  • Index(es):
    • Date
    • Thread