• 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: NSView subclass
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSView subclass


  • Subject: Re: NSView subclass
  • From: Scott Andrew <email@hidden>
  • Date: Wed, 15 Oct 2008 14:30:06 -0700

If its a delegate you would want to check if the delegate handles the selector with respondsToSelector and the use performSelector to make the call. For example....

if ([delegate respondsToSelector:@selector(pointClicked:)])
[delegate performSelector:@selector(pointClicked:) withObject: [NSValue valueWithPoint:(pt)]];


This should work. I believe the NSValue will resolve to the NSPoint in runtime.

Scott Andrew


On Oct 15, 2008, at 2:15 PM, DKJ wrote:

I've written a subclass of NSView. It calls a method its delegate can implement to detect mouse clicks. I've put something like this in the header file:

// delegate method:
@interface NSObject ()
- (void)pointClicked:(NSPoint)point;
@end

This is enough to prevent a "no -pointClicked: method found" compiler warning. But is it the best way to do it?

dkj
_______________________________________________

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


  • Follow-Ups:
    • Re: NSView subclass
      • From: Jonathan Hess <email@hidden>
References: 
 >NSView subclass (From: DKJ <email@hidden>)

  • Prev by Date: NSView subclass
  • Next by Date: Re: NSView subclass
  • Previous by thread: NSView subclass
  • Next by thread: Re: NSView subclass
  • Index(es):
    • Date
    • Thread