Re: setNeedsDisplayInRect and performSelectorOnMainThread?
Re: setNeedsDisplayInRect and performSelectorOnMainThread?
- Subject: Re: setNeedsDisplayInRect and performSelectorOnMainThread?
- From: Darkshadow <email@hidden>
- Date: Sun, 21 Jan 2007 20:23:46 -0500
On Jan 20, 2007, at 7:03 PM, Julien Jalon wrote:
setNeedsDisplayInRect: requests a NSRect as an argument, not a an
NSValue encapsulating an NSRect.
Of course, you can't pass the NSRect directly to
performSelectorOnMainThread.
So you will have to implement something like
setNeedsDisplayInRectAsValue: and use that.
--
Julien
I use an NSInvocation to do this:
NSInvocation *redrawInv = [NSInvocation invocationWithMethodSignature:
[self methodSignatureForSelector:@selector(setNeedsDisplayInRect:)]];
[redrawInv setTarget:self];
[redrawInv setSelector:@selector(setNeedsDisplayInRect:)];
[redrawInv setArgument:&r atIndex:2];
[redrawInv retainArguments];
[redrawInv performSelectorOnMainThread:@selector(invoke)
withObject:nil waitUntilDone:NO];
Or, if you just want setNeedsDisplay:
BOOL display = YES;
NSInvocation *redrawInv = [NSInvocation invocationWithMethodSignature:
[self methodSignatureForSelector:@selector(setNeedsDisplay:)]];
[redrawInv setTarget:self];
[redrawInv setSelector:@selector(setNeedsDisplay:)];
[redrawInv setArgument:&display atIndex:2];
[redrawInv retainArguments];
[redrawInv performSelectorOnMainThread:@selector(invoke)
withObject:nil waitUntilDone:NO];
Darkshadow
(aka Michael Nickerson)
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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