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