• 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
Cocoa alternative for method aliasing?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Cocoa alternative for method aliasing?


  • Subject: Cocoa alternative for method aliasing?
  • From: Lou Zell <email@hidden>
  • Date: Tue, 29 Mar 2011 11:20:31 -0700

Mornin' Devs,

Is there a recommended pattern for passing events up the responder chain
without subclassing a class and overriding the methods I'm interested in?
 Here is an explanation of what I'm trying to do:

I have a subclass of UIButton, call it MyButton, that I would like to
function as a vanilla UIButton but also pass touch events to the next
responder (I'm interested in eventually getting the events in
UIViewController).  I can do something like this in MyButton:

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
  [[self nextResponder] touchesBegan:touches withEvent:event];
}

But then I lose the touch handling that makes a UIButton different from just
a plain old UIView (e.g. highlight states).  I could use [self
setHighlighted:YES], for example, to fix that problem.  What I really want
to do, though, is something like this:

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
  [self originalTouchesBegan:touches withEvent:event];
  [[self nextResponder] touchesBegan:touches withEvent:event];
}

Something analogous to ruby's alias.  I haven't found anything built in for
method aliasing, which leads me to believe there is another way to approach
this.  Does anyone have a good approach?

Thanks,
Lou
_______________________________________________

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: Cocoa alternative for method aliasing?
      • From: David Duncan <email@hidden>
  • Prev by Date: Re: OCTET_STRING_t -> NSString?
  • Next by Date: Re: Cocoa alternative for method aliasing?
  • Previous by thread: Re: OCTET_STRING_t -> NSString?
  • Next by thread: Re: Cocoa alternative for method aliasing?
  • Index(es):
    • Date
    • Thread