Mount ... unmount events

Discussion in 'Mac Programming' started by multinode, Jun 2, 2011.

  1. macrumors regular

    Joined:
    Feb 4, 2011
    #1
    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?
     
  2. macrumors 68000

    Sydde

    Joined:
    Aug 17, 2009
    #2
    It would probably be the easiest.
     
  3. macrumors 603

    Joined:
    Aug 9, 2009
    #3
    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.
     
  4. thread starter macrumors regular

    Joined:
    Feb 4, 2011
    #4
    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).

     
  5. macrumors 603

    Joined:
    Aug 9, 2009
    #5
    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.
     
  6. thread starter macrumors regular

    Joined:
    Feb 4, 2011
    #6
    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.

     
  7. macrumors 603

    Joined:
    Aug 9, 2009
    #7
    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.
     
  8. thread starter macrumors regular

    Joined:
    Feb 4, 2011
    #8
    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.

     

Share This Page