• 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: Why [NSApp run] is required for this cocoa application
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Why [NSApp run] is required for this cocoa application


  • Subject: Re: Why [NSApp run] is required for this cocoa application
  • From: j o a r <email@hidden>
  • Date: Wed, 24 Aug 2005 13:45:25 +0200


On 24 aug 2005, at 13.26, prashant sharma wrote:

In my cocoa application, i created an observer for notifications from NSWorkspace notification center. I am not interacting with window server in any way. I want that i should be able to create a simple NSThread that should keep running and my observor should catch all the notifications at workspace notification center.
My question is why do we need NSApp run method in this case. I tried creating a thread and putting it in while(1) loop but thread came out of the loop after iterating over it for some time. Whole thing works fine if i use NSApp run method.
I am confused that why we need to call run.

What you probably didn't have was an idle NSRunLoop in your thread. If you don't have a run loop, or if it's never given a chance to run / be idle, there are a lot of things in Cocoa that might not work like you expect. You can't block a thread with "while(1)" and expect it to be responsive to notifications at the same time.


j o a r


Attachment: smime.p7s
Description: S/MIME cryptographic signature

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Why [NSApp run] is required for this cocoa application (From: "prashant sharma" <email@hidden>)

  • Prev by Date: Why [NSApp run] is required for this cocoa application
  • Next by Date: Re: svn: Can't open '/svnrep/db/current.tmp': Permission denied
  • Previous by thread: Why [NSApp run] is required for this cocoa application
  • Next by thread: Invoking XCode documentation from external apps?
  • Index(es):
    • Date
    • Thread