Re: Problem with NSWorkspaceDidMountNotification
Re: Problem with NSWorkspaceDidMountNotification
- Subject: Re: Problem with NSWorkspaceDidMountNotification
- From: Bob Ippolito <email@hidden>
- Date: Mon, 9 May 2005 18:32:02 -0400
On May 9, 2005, at 5:28 PM, Glenn Zelniker wrote:
I'm writing an application that reads data from a set of DVDs or
CDs. While the app is running, the user can attempt to load a piece
of data from one of the discs. The app detects whether or not the
disc is mounted and, if not, prompts the user to insert the
required disc. At this point, I would like to make use of
NSWorkspace's notifications, specifically
NSWorkspaceDidMountNotification, and then check to see if the disc
is among the workspace's mountedRemovableMedia.
I have verified that the notifications work as expected. That is, I
can indeed receive the desired notification and I can check the
volume name to see if it's the one I want. But I'm having a problem
making it work properly within the method in which I want it to
work. If I register for the notification in my controller's -
awakeFromNib method, I can get the notification while the
application is idling. But when I try to wait for notification
within a loop that looks like this:
###############
mounted = NO;
while (!mounted)
{
-- wait, do other stuff --
}
###############
Notifications don't work like that. If the event loop isn't pumping
then you can't receive the notification and the mounted variable
isn't going to change. They aren't hardware interrupts or signals!
You should restructure your application such that it is properly
event driven, which means that all of your methods have to return as
soon as possible. The best way to go about it would probably be to
put a sheet up with this message for the user (which should disable
the rest of the window) and take it down when the disk is inserted
(or the user cancels).
-bob
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden