• 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: [FIXED] calling scrollPoint: on table view from separate thread locks up app
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [FIXED] calling scrollPoint: on table view from separate thread locks up app


  • Subject: Re: [FIXED] calling scrollPoint: on table view from separate thread locks up app
  • From: Alastair Houghton <email@hidden>
  • Date: Thu, 9 Aug 2007 23:26:52 +0100

On 9 Aug 2007, at 22:11, Chase wrote:

in case someone 10 years from now is searching through the list archives for an answer to this question, here's what i did...

in init:

[[NSDistributedNotificationCenter defaultCenter] addObserver:self selector:@selector(testnotificationreceiver:) name:@"ANIMALCRACKERS" object:nil suspensionBehavior:NSNotificationSuspensionBehaviorDeliverImmediately] ;


in thread:

[[NSDistributedNotificationCenter defaultCenter] postNotificationName:@"ANIMALCRACKERS" object:nil userInfo:nil deliverImmediately:YES];

That's almost spectacularly baroque :-)

What was wrong with

  [myObject performSelectorOnMainThread:@selector(doSomeScrolling:)
                             withObject:nil
                          waitUntilDone:NO];

?

Also, I know this was just a test, but consider using capitalisation at word boundaries in method names (like the framework does)... it's more readable and others will thank you for it. And if you're using NSDistributedNotificationCenter, you should remember that you're going to send your notification to *every* other task on the system (at least, any that are listening), so it's important that your notification name is suitably unique. I would suggest that "ANIMALCRACKERS" probably isn't such a great idea in that regard.

Anyway, don't use NSDistributedNotificationCenter for inter-thread communication. Just use the -performSelectorOnMainThread: method I showed above. It's simpler and there's no chance of conflicts with other applications.

Kind regards,

Alastair.

--
http://alastairs-place.net




_______________________________________________

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: [FIXED] calling scrollPoint: on table view from separate thread locks up app (From: "Chase" <email@hidden>)

  • Prev by Date: Re: Copy-dragging in an NSTableView
  • Next by Date: Re: NSTableView clickedColumn clickedRow implementation
  • Previous by thread: Re: [FIXED] calling scrollPoint: on table view from separate thread locks up app
  • Next by thread: Re: [FIXED] calling scrollPoint: on table view from separate thread locks up app
  • Index(es):
    • Date
    • Thread