Blog

Preventing Services from activating your application

Posted by Tim Wood on 11.28.07 @ 5:59 PM File Under: Mac OS X Development

I failed to find any way to do this via the internets; but gdb, and some kindly soul inside Apple, met the challenge:

(gdb) b -[NSUserDefaults objectForKey:]

Breakpoint 17 at 0x94172fa4

(gdb) c

Continuing.

... invoke service, hit breakpoint ...

(gdb) po *(id *)($fp + 16)

NSShouldActivateForServiceRequest

(gdb)

Is there a better way to do this?  Google and mdls don't seem to know about NSShouldActivateForServiceRequest at all, so I'm guessing not.

  1. Peter Jaros

    11.28.07 10:53 PM

    Lest I state the obvious, have you tried setting NSShouldActivateForServiceRequest to NO?  Or are you looking for a better way than that?


    (Or have I misread your gdb session?)

  2. Tim

    11.29.07 5:10 AM

    That's exactly what I'm doing now—the problem is that this default isn't documented anywhere that I can find.  Nor is any other way of doing this documented (also, the normal behavior is bad—if I wanted my app to activate when the service was invoked, I'd tell it to!)

  3. Peter Jaros

    11.29.07 10:12 PM

    Hmm.  Have you tried breaking on respondsToSelector:?  Perhaps there's a delegate method that controls this.  Although you're right, it *is* a weird default.

  4. ken

    12.23.07 4:51 PM

    I vaguely think I remember someone telling me about this.. I think Cocoa uses a heuristic to guess whether activating is appropriate.


    If you didn't file a bug for API, please do.

Commenting is not available in this section entry.