Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

multinode

macrumors regular
Original poster
Feb 4, 2011
150
0
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?
 

chown33

Moderator
Staff member
Aug 9, 2009
10,750
8,422
A sea of green
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

macrumors regular
Original poster
Feb 4, 2011
150
0
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

Moderator
Staff member
Aug 9, 2009
10,750
8,422
A sea of green
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

macrumors regular
Original poster
Feb 4, 2011
150
0
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

Moderator
Staff member
Aug 9, 2009
10,750
8,422
A sea of green
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

macrumors regular
Original poster
Feb 4, 2011
150
0
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.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.