Disk insert event

  • I have been trying to catch disk mount and unmount events but I can't
    figure it out. I want to be notified when a volume is either mounted
    or unmounted. I tried this:

    - (void)awakeFromNib
    {
      [[NSNotificationCenter defaultCenter] addObserver:self
      selector:@selector(diskMountChanged:)
      name:NSWorkspaceDidMountNotification
      object: [NSWorkspace sharedWorkspace]];
    }

    and

    // tells us if a disk was mounted
    -(void)diskMountChanged:(NSNotification *)notification
    {
    NSLog(@"Disk mounted");
    } // diskMountChanged

    I tried to open a dmg and popped in a USB flash drive but I never get
    an event. What am I doing wrong ?

    Thanks,
    Matt
  • oops, wrong notification center. need to get it from NSWorkspace

    Sorry,
    Matt

    On Oct 12, 2006, at 8:16 PM, Matt Mashyna wrote:

    > I have been trying to catch disk mount and unmount events but I
    > can't figure it out. I want to be notified when a volume is either
    > mounted or unmounted. I tried this:
    >
    > - (void)awakeFromNib
    > {
    > [[NSNotificationCenter defaultCenter] addObserver:self
    > selector:@selector(diskMountChanged:)
    > name:NSWorkspaceDidMountNotification
    > object: [NSWorkspace sharedWorkspace]];
    > }
    >
    > and
    >
    > // tells us if a disk was mounted
    > -(void)diskMountChanged:(NSNotification *)notification
    > {
    > NSLog(@"Disk mounted");
    > } // diskMountChanged
    >
    >
    > I tried to open a dmg and popped in a USB flash drive but I never
    > get an event. What am I doing wrong ?
    >
    > Thanks,
    > Matt
    > _______________________________________________
    > Do not post admin requests to the list. They will be ignored.
    > Cocoa-dev mailing list      (<Cocoa-dev...>)
    > Help/Unsubscribe/Update your Subscription:
    > http://lists.apple.com/mailman/options/cocoa-dev/<mashyna...>
    >
    > This email sent to <mashyna...>
    >
previous month october 2006 next month
MTWTFSS
            1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31          
Go to today