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

Multithreaded NSView:setNeedsDisplay:


  • Subject: Multithreaded NSView:setNeedsDisplay:
  • From: Rony Kubat <email@hidden>
  • Date: Tue, 4 Dec 2007 01:03:53 -0500

Hello,

I'm trying to find the "correct" way to request a view to repaint from a thread other than the main one. I've seen this question asked before, but I haven't seen an answer that is both (1) elegant, and (2) works. I was hoping that someone could point me in the right direction.

Say I have this:
	NSView* view;
and I want to call
	[view setNeedsDisplay:YES];
from a thread other than main.

From what I've read elsewhere, I would love to do something like this:

[view performSelectorOnMainThread:@selector(setNeedsDisplay:) withObject:YES waitUntilDone:NO];

Unfortunately, this doesn't work because YES is not an object. My current solution is to create a proxy method:

	- (void) redisplay
	{
	    [self setNeedsDisplay:YES];
	}


And call it like this:

[view performSelectorOnMainThread:@selector(redisplay) withObject:YES waitUntilDone:NO];

But this is ugly. Is there a better way? Bummer that setNeedsDisplay: is not threadsafe. Bummer that it requires an argument at all...

Cheers,
-Rony Kubat
_______________________________________________

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: Multithreaded NSView:setNeedsDisplay:
      • From: Scott Anguish <email@hidden>
  • Prev by Date: Re: ANN: New Book “Cocoa Design Patterns”
  • Next by Date: Re: Help diagnosing memory problem
  • Previous by thread: Re: Help diagnosing memory problem
  • Next by thread: Re: Multithreaded NSView:setNeedsDisplay:
  • Index(es):
    • Date
    • Thread