views:

64

answers:

3

Hello,

I have a problem using DiskArbitration framework, to catch disk image mounting I register for

DARegisterDiskMountApprovalCallback

The problem is that each time a disk image is mounted the callback is called twice.

Why is that and how can I solve this ?

Thanks.

A: 

I use these the catch that. I'm not sure of the difference these are to what you're doing but they work.

    [[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector:@selector(mediaMounted:) name:NSWorkspaceDidMountNotification object:[NSWorkspace sharedWorkspace]];
[[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector:@selector(mediaUnmounted:) name:NSWorkspaceWillUnmountNotification object:[NSWorkspace sharedWorkspace]];
regulus6633
I can't use NSWorkspace, it comes from appKit which isn't not daemon safe, and I need to run this as a daemon.
Benj
A: 

Did you put a breakpoint in your callback to see what are the call-stack when it is called ? It can gives you some hints on what is going on.

Laurent Etiemble
Most the time I hit the breakpoint only once..
Benj
@Nyxem When it is hit twice, does the callstack gives you some information ?
Laurent Etiemble
+1  A: 

I end up coding something to detect the 2nd mount and ignore it, thanks for your help people.

Benj