• 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: Possible to determine who called a method?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Possible to determine who called a method?


  • Subject: Re: Possible to determine who called a method?
  • From: Jaime Magiera <email@hidden>
  • Date: Thu, 1 Nov 2007 14:55:08 -0400


On Nov 1, 2007, at 2:19 PM, Ken Tozier wrote:

Hi

Say you have several objects "A," "B," "C," which contain references to each other in an NSArray. Is it possible inside each object's doSomethingAmazing method to determine which object called it? For example: Say Object C receives a doSomethingAmazing invocation. It should do its thing and then notify it's siblings to run their own doSomethingAmazing methods but because each contains references to all the others, it could enter an infinite loop. Here's an example:

Hi Ken,

I actually asked this question a few weeks ago. The general consenous is that it is not possible within the constructs of the language. However, you can add a "sender" parameter to your methods to get the same result. For example...

-(BOOL) doSomethingWith:(id) anObject sender:(id)whoMadeTheCall
{


}

...

[class doSomethingWith:anObject sender:self];

I've been doing this now in terms of passing sender around for notifications, and it works great.

HTH,

Jaime Magiera
Sensory Research
http://www.sensoryresearch.net




_______________________________________________

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: 
 >Possible to determine who called a method? (From: Ken Tozier <email@hidden>)

  • Prev by Date: Re: "linked on Leopard"?
  • Next by Date: Re: When should one call unbind:? (in a GC application)
  • Previous by thread: Re: Possible to determine who called a method?
  • Next by thread: Is NSXMLParser really a streaming parser?
  • Index(es):
    • Date
    • Thread