PDA

View Full Version : Mount ... unmount events




multinode
Jun 2, 2011, 06:56 PM
My app needs to respond to Mount and Unmount events of removable volumes. What is the best class to use? Is NSWorkspace a good choice?



Sydde
Jun 2, 2011, 07:25 PM
It would probably be the easiest.

chown33
Jun 2, 2011, 07:34 PM
My app needs to respond to Mount and Unmount events of removable volumes. What is the best class to use?

Without knowing what you mean by "respond to", it's impossible to say what might be "best". If you have a specific action in mind, you'll have to say what that specific action is.

Is NSWorkspace a good choice?
Try it. See what happens. Post the results.


In the absence of any information about what you're trying to accomplish, NSWorkspace seems like a good starting point to me. If you have specific reasons to think otherwise, or have encountered a specific problem, you'll have to post the reasons or the problems.

multinode
Jun 2, 2011, 09:23 PM
Hey CHOWN33 ... you've been quite helpful before ... so:

An SD card is inserted into a USB card reader by my customer or one of our admins. The server side of my app on a MBP or MacMini must see that insertion and respond by reading from (or writing to) the SD card.

I did exactly this in Carbon/C a few years ago and it (still) runs on my 10.6.4. However, I'd like to do a QUICK port to ObjC if possible ... so that everything is current technology (haha).

Without knowing what you mean by "respond to", it's impossible to say what might be "best". If you have a specific action in mind, you'll have to say what that specific action is.


Try it. See what happens. Post the results.


In the absence of any information about what you're trying to accomplish, NSWorkspace seems like a good starting point to me. If you have specific reasons to think otherwise, or have encountered a specific problem, you'll have to post the reasons or the problems.

chown33
Jun 3, 2011, 01:05 AM
An SD card is inserted into a USB card reader by my customer or one of our admins. The server side of my app on a MBP or MacMini must see that insertion and respond by reading from (or writing to) the SD card.

NSWorkspace should be fine. Try it. See if it works.

One thought: if you have to write to the SD card, be prepared for it to fail. The SD might be write-protected, or it might be a read-only file-system.

multinode
Jun 3, 2011, 01:39 AM
Thanx for the remark vis-a-vis the SD card. That won't be a problem because it is guaranteed not to be write protected and the FS will be read/write.

Btw, did you see my new post about writing a command line app? All of the questions I've been posting relate to one company project.

Thank you CHOWN33.

NSWorkspace should be fine. Try it. See if it works.

One thought: if you have to write to the SD card, be prepared for it to fail. The SD might be write-protected, or it might be a read-only file-system.

chown33
Jun 3, 2011, 01:50 AM
Btw, did you see my new post about writing a command line app? All of the questions I've been posting relate to one company project.

You'll also need to learn about NSRunLoop, too. The mount/unmount notifications depend on an active run loop, IIRC (but I could be wrong about that).

If you've never dealt directly with an NSRunLoop before, I expect you will have trouble understanding it, especially in the context of a command-line tool. It's going to seem like dark magic until you figure it out. You should probably spend some time finding examples of NSRunLoop in command line tools.

multinode
Jun 3, 2011, 02:46 AM
Thanx again. I will review the old Carbon/C stuff that I did. I remember dealing with NSRunLoop, so it might not be too painful. Btw, much of Carbon's stuff was black magic. :)

CHOWN33: what is your Skype name? I'd like to discuss something with you that would be against Forum rules to post here. My Skype name is multinode.

You'll also need to learn about NSRunLoop, too. The mount/unmount notifications depend on an active run loop, IIRC (but I could be wrong about that).

If you've never dealt directly with an NSRunLoop before, I expect you will have trouble understanding it, especially in the context of a command-line tool. It's going to seem like dark magic until you figure it out. You should probably spend some time finding examples of NSRunLoop in command line tools.