Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Jun 2, 2011, 06:56 PM   #1
multinode
macrumors regular
 
Join Date: Feb 2011
Mount ... unmount events

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?
__________________
PLEASE DON'T SUPPORT ANTI AMERICA WIKILEAKS ... CUTE BUT DESTRUCTIVE
multinode is offline   0 Reply With Quote
Old Jun 2, 2011, 07:25 PM   #2
Sydde
macrumors 68000
 
Sydde's Avatar
 
Join Date: Aug 2009
It would probably be the easiest.
__________________
You got to be a spirit. You can't be no ghost.
Sydde is offline   0 Reply With Quote
Old Jun 2, 2011, 07:34 PM   #3
chown33
macrumors 603
 
Join Date: Aug 2009
Quote:
Originally Posted by multinode View Post
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.

Quote:
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.
chown33 is offline   0 Reply With Quote
Old Jun 2, 2011, 09:23 PM   #4
multinode
Thread Starter
macrumors regular
 
Join Date: Feb 2011
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).

Quote:
Originally Posted by chown33 View Post
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.
__________________
PLEASE DON'T SUPPORT ANTI AMERICA WIKILEAKS ... CUTE BUT DESTRUCTIVE
multinode is offline   0 Reply With Quote
Old Jun 3, 2011, 01:05 AM   #5
chown33
macrumors 603
 
Join Date: Aug 2009
Quote:
Originally Posted by multinode View Post
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.
chown33 is offline   0 Reply With Quote
Old Jun 3, 2011, 01:39 AM   #6
multinode
Thread Starter
macrumors regular
 
Join Date: Feb 2011
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.

Quote:
Originally Posted by chown33 View Post
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.
__________________
PLEASE DON'T SUPPORT ANTI AMERICA WIKILEAKS ... CUTE BUT DESTRUCTIVE
multinode is offline   0 Reply With Quote
Old Jun 3, 2011, 01:50 AM   #7
chown33
macrumors 603
 
Join Date: Aug 2009
Quote:
Originally Posted by multinode View Post
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.
chown33 is offline   0 Reply With Quote
Old Jun 3, 2011, 02:46 AM   #8
multinode
Thread Starter
macrumors regular
 
Join Date: Feb 2011
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.

Quote:
Originally Posted by chown33 View Post
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.
__________________
PLEASE DON'T SUPPORT ANTI AMERICA WIKILEAKS ... CUTE BUT DESTRUCTIVE
multinode is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
HD won't unmount nyroger iMac 3 Jan 16, 2014 08:01 PM
iPhoto - Creating 'Events' within 'Events'? Big Stevie Mac Applications and Mac App Store 47 Aug 26, 2013 02:30 PM
Unmount or eject hd? Apple Corps OS X 10.8 Mountain Lion 4 Dec 15, 2012 04:13 PM
Applescript to unmount/mount drive on identifier other than volume name? mixvio OS X 10.8 Mountain Lion 0 Sep 6, 2012 04:20 AM
Mount and unmount optibay HDD like external ratboy90 MacBook Pro 7 Jul 14, 2012 12:06 PM

Forum Jump

All times are GMT -5. The time now is 03:43 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC