Re: Why [NSApp run] is required for this cocoa application
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