• 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: Oh notification, where are you?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Oh notification, where are you?


  • Subject: Re: Oh notification, where are you?
  • From: Michael Thon <email@hidden>
  • Date: Tue, 22 Sep 2009 08:20:59 +0200


On Sep 22, 2009, at 3:03 AM, Rob Keniger wrote:


On 22/09/2009, at 2:31 AM, Michael Thon wrote:

	NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
	[nc addObserver:self
		   selector:@selector(sendNotification:)
			   name:@"NSMetadataQueryDidFinishGatheringNotification"
			 object:nil];
	[myThread start];

In the sendNotification: method I send the notification to the other thread using performSelector: onThread: however sendNotification: is never even called. Either the notifications are not, in fact being sent to the main thread or I'm doing something else wrong. There is probably something basic about threads or notifications that I don't understand but I have run out of ideas about what to try next.


NSMetadataQueryDidFinishGatheringNotification is a string constant, so you should use it directly and not put it inside the @"" string literal container:

	NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
	[nc addObserver:self
		   selector:@selector(sendNotification:)
			   name:NSMetadataQueryDidFinishGatheringNotification
			 object:nil];


@Rob - thanks for pointing that out

I did find the problem - my thread needs a runloop in order to process notifications. Following this fellow's blog post:
http://confuseddevelopment.blogspot.com/2006_10_01_archive.html
I added CFRunLoopRun(); after starting the metadataquery. Inside the method that gets called to process the notification I added: CFRunLoopStop(CFRunLoopGetCurrent ()); to stop the runloop.





_______________________________________________

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: Oh notification, where are you?
      • From: James Bucanek <email@hidden>
    • Re: Oh notification, where are you?
      • From: Jerry Krinock <email@hidden>
References: 
 >Oh notification, where are you? (From: Michael Thon <email@hidden>)
 >Re: Oh notification, where are you? (From: Rob Keniger <email@hidden>)

  • Prev by Date: Making the Text in a Text Cell change color when the Rows Checkbox has been checked.
  • Next by Date: Re: Making the Text in a Text Cell change color when the Rows Checkbox has been checked.
  • Previous by thread: Re: Oh notification, where are you?
  • Next by thread: Re: Oh notification, where are you?
  • Index(es):
    • Date
    • Thread