• 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: Qustion about possibly bad advice in NSView documentation
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Qustion about possibly bad advice in NSView documentation


  • Subject: Re: Qustion about possibly bad advice in NSView documentation
  • From: glenn andreas <email@hidden>
  • Date: Tue, 25 Sep 2007 10:36:07 -0500


On Sep 25, 2007, at 10:25 AM, Shawn Erickson wrote:


On Sep 25, 2007, at 8:11 AM, Erik Buck wrote:

Indeed, you can wrap NSRect structures in an NSValue object. That doesn't help in this case. The documentation seems to be suggesting that the following is valid (I don't think it is):

- (void)drawRect:(NSRect)aRect
{
[self performSelector:@selector(setNeedsDisplayInRect:) withObject:NSMakeRect(0,0, 100, 100) afterDelay:0.0];
}



Even if this is changed to use NSValue, it doesn't help:

- (void)drawRect:(NSRect)aRect
{
[self performSelector:@selector(setNeedsDisplayInRect:) withObject:[NSValue valueWithRect:NSMakeRect(0,0, 100, 100)] afterDelay:0.0];
}


I doesn't help because the setNeedsDisplayInRect: method is not expecting an NSValue argument; it's expecting an NSRect structure argument.

Provide a setNeedsDisplayInRect:(NSValue*) in the target object that knows how to deal with the NSValue encoded NSRect.


...or use a trampoline object to do this...

[[self performLater] setNeedsDisplayInRect:NSMakeRect(0,0, 100, 100)];

... of course you have to implement the magic to do the above. You can find some code online for this type of thing (HOM, higher order messaging).

You could also make an NSInvocation and have _that_ performed.

Roughly typed in mail:

NSMethodSignature *sig = [self methodSignatureForSelector:@selector (setNeedsDisplayInRect:)];
NSInvocation *invoc = [NSInvocation invocationWithMethodSignature: sig];
[invoc setSelector: @selector(setNeedsDisplayInRect:)];
NSRect rect = NSMakeRect(0,0,100,100);
[invoc setArgument: &rect atIndex: 2];
[invoc performSelector: @selector(invokeWithTarget:) withObject: self afterDelay: 0.0];



Glenn Andreas email@hidden
<http://www.gandreas.com/> wicked fun!
quadrium2 | build, mutate, evolve, animate | images, textures, fractals, art



_______________________________________________

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: 
 >Re: Qustion about possibly bad advice in NSView documentation (From: Erik Buck <email@hidden>)
 >Re: Qustion about possibly bad advice in NSView documentation (From: Shawn Erickson <email@hidden>)

  • Prev by Date: Re: Qustion about possibly bad advice in NSView documentation
  • Next by Date: Re: Qustion about possibly bad advice in NSView documentation
  • Previous by thread: Re: Qustion about possibly bad advice in NSView documentation
  • Next by thread: Re: Qustion about possibly bad advice in NSView documentation
  • Index(es):
    • Date
    • Thread