• 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: Forwarding messages from an application delegate
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Forwarding messages from an application delegate


  • Subject: Re: Forwarding messages from an application delegate
  • From: "Matthew Gertner" <email@hidden>
  • Date: Fri, 2 May 2008 16:56:19 +0200

Seems like you can "pretend" you implement them using
respondsToSelector (see Graham's reply).

On Fri, May 2, 2008 at 4:53 PM, Andy Lee <email@hidden> wrote:
> Delegate methods aren't sent at all unless the delegate implements them.  I
> think your delegate is going to have to implement all possible delegate
> methods and then forward them *if* the old delegate implements them, and
> otherwise return an appropriate default value if there is a return value.
>
>  This means the application will send all possible delegate methods to you,
> as opposed to just the ones the old delegate implements, but hopefully that
> won't cause any problems.  I suppose you could do some low-level hacking
> where you detect which methods the old delegate implements and then remove
> unneeded methods from your delegate class.
>
>  --Andy
>
>
>
>  On May 2, 2008, at 10:35 AM, Matthew Gertner wrote:
>
> >
> >
> >
> > Hi,
> >
> > I am implementing an application delegate for a framework (Mozilla)
> > that already registers its own delegate internally. Ideally I would
> > like to be able to handle specific delegate messages in my class (in
> > this case adding items to the dock tile menu) and forward all other
> > invocations to the old delegate. So before I call [[NSApplication
> > sharedApplication] setDelegate] for my delegate, I retrieve the
> > existing delegate and save it in a member variable (mOldDelegate). I
> > thought that I could get invocations to forward automatically like
> > this:
> >
> > - (void)forwardInvocation:(NSInvocation *)anInvocation
> > {
> > if ([mOldDelegate respondsToSelector:[anInvocation selector]])
> >  [anInvocation invokeWithTarget:mOldDelegate];
> > else
> >  [super forwardInvocation:anInvocation];
> > }
> >
> > - (NSMethodSignature *)methodSignatureForSelector:(SEL)aSelector
> > {
> > if ([mOldDelegate respondsToSelector:aSelector])
> >  return [mOldDelegate methodSignatureForSelector:aSelector];
> > else
> >  return [super methodSignatureForSelector: aSelector];
> > }
> >
> > For some reason neither methodSignatureForSelector nor
> > forwardInvocation is ever called. Perhaps this has something to do
> > with the way messages are sent to the delegate by the application. As
> > a result, my delegate never forwards to the old delegate. Any guidance
> > would be appreciated.
> >
> > Matt
> >
> > _______________________________________________
> >
> > 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
> >
>
>  _______________________________________________
>
>  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
>



--
*** Note that my email has changed to email@hidden.
Please update your address book accordingly. ***
_______________________________________________

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

  • Follow-Ups:
    • Re: Forwarding messages from an application delegate
      • From: Graham Cox <email@hidden>
References: 
 >Forwarding messages from an application delegate (From: "Matthew Gertner" <email@hidden>)
 >Re: Forwarding messages from an application delegate (From: Andy Lee <email@hidden>)

  • Prev by Date: Re: Forwarding messages from an application delegate
  • Next by Date: Re: Displaying one NSTextStorage with two sets of temporary attributes
  • Previous by thread: Re: Forwarding messages from an application delegate
  • Next by thread: Re: Forwarding messages from an application delegate
  • Index(es):
    • Date
    • Thread