Re: Still need help with Services. Is there sample code?
Re: Still need help with Services. Is there sample code?
- Subject: Re: Still need help with Services. Is there sample code?
- From: Keary Suska <email@hidden>
- Date: Tue, 16 Sep 2014 08:17:17 -0600
On Sep 16, 2014, at 6:22 AM, Daryle Walker <email@hidden> wrote:
> Still can’t get my Service to trigger.
>
>> daryle$ /Applications/TextEdit.app/Contents/MacOS/TextEdit -NSDebugServices io.github.me.MyApp
>> 2014-09-16 08:00:58.493 TextEdit[546:507] NSDebugServices=io.github.me.MyApp
>> Open URL (io.github.me.MyApp) is explicitly enabled in the services menu and enabled in the context menu, in preferences.
>> Open URL (io.github.me.MyApp) is explicitly enabled in the services menu and enabled in the context menu, in preferences.
>> Open URL (io.github.me.MyApp) is disqualified because its send and/or return types cannot be handled by the requestor <NSTextView: 0x7fc35345d950>
>> Frame = {{0.00, 0.00}, {550.00, 420.00}}, Bounds = {{0.00, 0.00}, {550.00, 420.00}}
>> Horizontally resizable: NO, Vertically resizable: YES
>> MinSize = {550.00, 420.00}, MaxSize = {179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.00, 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.00}
>> .
>
> The first two lines after the command always appear. The rest of the lines happen every time I open the Services menu, no matter the context. (The error messages are happening when the system checks if my Service qualifies.) Web-searching got only one hit on "is disqualified because its send and/or return types cannot be handled by the requestor”; the page was from Stack Overflow. It mentioned a post on this list from 5 years ago, suggesting adding an “NSRequiredContext” entry. It didn’t help me; still getting the same error. (The “MaxSize” numbers are one huge line; it wraps here.)
>
> I’m stumped. I’ve been looking for Apple sample code, but since it likes tacking on “service” to 80% of its stuff, I can’t find anything.
>
> Here’s the Services portion of my Info.plist, in case I’m still missing something simple:
>
>> <key>NSServices</key>
>> <array>
>> <dict>
>> <key>NSMenuItem</key>
>> <dict>
>> <key>default</key>
>> <string>Open URL</string>
>> </dict>
>> <key>NSMessage</key>
>> <string>openURL</string>
>> <key>NSPortName</key>
>> <string>Prairie</string>
>> <key>NSSendFileTypes</key>
>> <array>
>> <string>public.text</string>
>> </array>
>> <key>NSRequiredContext</key>
>> <dict>
>> <key>NSServiceCategory</key>
>> <string>public.text</string>
>> </dict>
>> </dict>
>> </array>
>
> I could post the source code again, but the lack of any logging from that method means the process is failing before the method would be called. I did at one time add an -init and -dealloc with logging just to make sure the object was created and retained. I got just the init message, which means that the service provider was being retained and not instant-deallocated.
>
> Oh, the Stack Overflow page was <http://stackoverflow.com/questions/1370616/nsservices-not-working> and the referenced post was <http://lists.apple.com/archives/Cocoa-dev/2009/Sep/msg00201.html>.
I am not sure how you are googling, but I found a solution as the first hit. I always do full phrase searches on error messges for best results. See this: http://lists.apple.com/archives/cocoa-dev/2012/Jun/msg00382.html as it has the exact same problem, with solution. Use that info.plist as a sample and see if you have better success.
Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden