Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[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



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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden
References: 
 >Re: [FIXED] calling scrollPoint: on table view from separate thread locks up app (From: "Chase" <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.