Re: [FIXED] calling scrollPoint: on table view from separate thread locks up app
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