The Blog

Preventing Services from activating your application

by Tim Wood on November 28, 2007

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.

 

Comments

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?)

Peter Jaros

11.28.07 11:53 PM

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!)

Tim

11.29.07 6:10 AM

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.

Peter Jaros

11.29.07 11:12 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.

ken

12.23.07 5:51 PM
Commenting is not available in this channel entry.