Regarding "there must be a reference to objA stored somewhere" I kinda figured as much - BUT - was hoping there might be another way especially since there are those OO purists that condemn the use of any sort of "globalness".
What I have is a view within the main window that is a Quartz 2D graphical "thing" and I want to have a set of UI elements that a user interacts with to change the graphical presentation. Well the UI elements are in the Delegate and the Graphical thing is in the view. The UI elements need to call methods in the view to change the graphical thing. So from what I think I read in your post I have to "store" objA's ID in a common ancestor. I'll have to ponder how to achieve that. YT On May 5, 2013, at 9:49 PM, Quincey Morris <quinceymor...@rivergatesoftware.com> wrote: > On May 5, 2013, at 21:43 , YT <y...@redwoodcontent.com> wrote: > >> In some thread an object is created with a set of methods. >> Lets call this object objA. >> >> Later in time another objected is created perhaps in another thread (not >> sure if this note is relevant). >> Lets call this object objB. >> >> Now objB needs to call a method in objA. >> >> Since objB came into being after objA how does objB detect that objA exists >> before attempting to call one of its methods? > > There's no magic here. If objB is to be aware of the existence of objA, there > must be a reference to objA stored somewhere. (In fact, normally, there has > to be a [strong] reference to objA store somewhere in order for objA to > continue to exist. Otherwise, it's leaked or deallocated, depending on how > you're handling memory management.) > > Usually, the reference to objA is held by some other object, whose existence > is known to B. For example, most applications have an application delegate > object that exists for the lifetime of the app, so this object could be > designed to hold a reference to objA. > > If necessary, you can create a global variable to hold the reference to objA, > but this would normally be done only if there were no context (that is, > object graph) to which objA naturally belongs. > _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com