What kind of service is this?

I asked what I thought would be a simple question on cocoa-dev:

I've added a system service to my app. I'd like it to appear in the "Search" group of the Services menu (where "Look Up in Dictionary" and "Search With Google" are) rather than the "Text" group.

I would have guessed there is some key-value pair I could set in the NSServices dictionary in Info.plist, but as far as I can tell my NSServices looks just like Safari's.

Here's what I meant by the "Search" group (actually I meant "Searching"):

Services searching

I waited a few days and no one replied, so I poked around some more. The short answer is that you add an entry to the NSRequiredContext dictionary using the undocumented key NSServiceCategory:

<key>NSRequiredContext</key>
<dict>
	<key>NSServiceCategory</key>
	<string>Searching</string>
</dict>

You can't create your own category. If you change "Searching" to "My Great Services", the Services menu doesn't add a "My Great Services" category containing your service. Instead, your service goes back into the catch-all "Text" category. There are at least eight names you can use:

  • Pictures
  • Internet
  • Files and Folders
  • Messaging
  • Searching
  • Text
  • Development
  • General

I got this list from System Preferences, in the Keyboard > Keyboard Shortcuts > Services pane:

Service category names

I had looked in the Info.plist files of Safari and Dictionary, but they don't use NSServiceCategory or I'd have found this answer a lot sooner. Nor does Mail, which appears in Services under "Messaging". Besides using Info.plist, Cocoa must have a secret registry somewhere that maps apps to Services categories.

I only discovered NSServiceCategory, which finally gave me something good to Google, when I thought to look inside Twitter and Tweetings, two apps that also manage not to be in the "Text" category. Instead of a category name, those apps use the UTI "public.item", which puts their services under "Files and Folders". That seems odd to me, but maybe that's their way of breaking out of the big undifferentiated "Text" category.

You can find other apps that use NSServiceCategory by running this command and grepping the results:

/System/Library/CoreServices/pbs -dump_pboard

Using NSServiceCategory was unofficially advised by Peter Ammon back in 2009. I've filed Radar #11945677 asking Apple to make it official in the Services Implementation Guide so that users can see their services properly categorized.


UPDATE: NSServiceCategory isn't the only setting that affects what category the service goes into. I noticed the Versions app doesn't have a NSServiceCategory setting, yet it appears in the "Internet" category, because of its NSTextContent setting:

<key>NSRequiredContext</key>
<dict>
	<key>NSTextContent</key>
	<string>URL</string>
</dict>

I updated my Radar to ask that this be documented as well.

How many Apple IDs do I have?

Today I was setting up a fresh OS install and noticed that in the Mac App Store, my "Purchases" list was missing many items. Only a handful of apps were listed, when it should have been dozens.

Others have had this problem, and for some people this advice has worked:

  1. Select Store > View My Account and sign in.
  2. Look for a section headed iTunes in the Cloud, with a Hidden Purchases entry, and click View Hidden Purchases.
  3. Click Unhide for those purchases you wish to appear in your App Store Purchases window, then click Done.

When I tried this, I didn't see anything about iTunes in the Cloud or Hidden Purchases.

Then I remembered that I've had problems before with my Developer account where I got different behaviors depending on whether I logged in with "aglee" or "aglee@mac.com" as my Apple ID. I logged out of the Mac App Store as "aglee@mac.com" and logged back in as "aglee", and all my purchases appeared again.

I'm guessing that at some point I accidentally created two separate Apple IDs, not realizing that logging in as "aglee" at mac.com was not the same as logging as "aglee@mac.com". One of these days I'll see if I can get the accounts reconciled. It's annoying having this dual identity with an identifier whose very purpose is to tie together all the ways in which I use Apple services. Bad enough that Apple gave me an unwanted me.com email address.

[UPDATE: While logged into the "wrong" account, before realizing that was the case, I clicked on an app that I already owned, expecting it would be treated as a re-download, but of course it was treated as a purchase. I contacted Apple and got a refund right away, no hassle, for the redundant purchase. I used the customer support link at the bottom of the receipt email. I asked about reconciling the two accounts and was told: "I am sorry but it's not possible to merge two or more iTunes Store accounts together."]

WWDC videos – SD vs. HD

By downloading the SD versions of the WWDC videos, you can have a complete set to watch much sooner than if you download the HD versions. Also, you have a much better chance of fitting the entire collection on your iDevice if you use the SD versions.

Here are the 2012 videos:

https://developer.apple.com/videos/wwdc/2012/

(This year Apple took only four days to make the videos available to all registered developers, which is really amazing. Thank you, Ron Okamoto!)

If you follow the link above you get to the HD versions of the videos in iTunes. That's a huge amount to download. If you click the "Developer on iTunes" breadcrumb on the upper right, you can get to the SD versions.

Developer on itunes

How much less are the SD videos to download than the HD ones? Doing a Get Info in Finder, I see that in 2010 the HD videos were about 32GB total, compared to 14GB for SD. Big difference, especially if your Internet access is not super-fast.

In 2011 Apple must have increased the resolution of the HD videos, because they totaled about 53GB. I assume the SD was again roughly half that, which would mean an even bigger size difference than in 2010.

Size differences

iTunes says there are only 210 SD tracks for WWDC 2012, compared to 224 HD ones. ("Tracks" seems to include the PDFs of the slides, so really it's about 110 videos.) I don't know what's missing on the SD side.

Number of tracks

In any case, I plan to download both sets, starting with SD so I'll have a complete set that much sooner. I do want the HD versions because they are noticeably nicer to watch. I seem to recall code samples sometimes being hard to read in the SD versions.

WWDC 2012, Day One

Got up early on Monday and walked over to Moscone with Lee (whom I'm sharing a hotel room with) and Howard (who's staying at the same hotel). Got on line for the keynote at 6:15 AM. We were joined by a few friends. Made it into the main room.

Keynote at 10:00 AM. Tim, Phil, Craig, and Scott did a great job. They transitioned smoothly, they were entertaining, they showed great stuff, they were all stars in their own ways. There was no ghost of Steve, and it felt appropriate to me that he was not mentioned. We've moved beyond that.

The demos were brisk and to-the-point. I have to say, sometimes Steve would linger a bit longer on a particular feature than I thought necessary.

I didn't lust for the Retina MacBook as I would have a year or two ago. As often happens, that may change when I get a chance to try one out in the store. I definitely can't justify getting one, though. My hardware needs are already well met, and then some.

I really enjoyed meeting up with friends.

In the evening, went with Lee to a NeXTSTEP retrospective hosted by Michael Johnson. It was a fundraiser for the Cartoon Art Museum. An amazing night. No time for details now.

Time to dive into Day 2.

Feynman's non-miraculous clock

Today I came across a blog post by Dan Nguyen, entitled "Feynman's Clock", that defends Richard Feynman from the stereotype of a genius scientist who is all brains and no feelings. I enjoyed the piece, but I have problems with it because it simultaneously perpetuates that very stereotype.

Nguyen talks about how Feynman reacted to the illness and death of his wife Arlene. Here's a quote from James Gleick's biography of Feynman (I assume the emphasis is Nguyen's):

Finally he heard a last small breath, and a nurse came and said that Arline was dead. He leaned over to kiss her and made a mental note of the surprising scent of her hair, surprising because it was the same as always.

The nurse recorded the time of death, 9:21 P.M. He discovered, oddly, that the clock had halted at that moment—just the sort of mystical phenomenon that appealed to unscientific people.

Then an explanation occurred to him. He knew the clock was fragile, because he had repaired it several times, and he decided that the nurse must have stopped it by picking it up to check the time in the dim light.

Seems reasonable to me. Here's Nguyen's commentary on that anecdote:

At a moment when just about anybody would shove aside rational thought – even at least as a helpless reaction to mindnumbing grief – and favor that the universe’s chaos stopped just then to offer a sign of divine significance, Feynman instead sticks to cold hard logic, even if it means sterilizing the moment of his wife’s death.

I disagree that the only natural reaction to grief is to "shove aside rational thought" and assume "divine significance" behind events that we would otherwise assume are coincidence.

I strongly disagree that Feynman "sterilized" the moment of Arlene's death, as if his use of reason devalued his emotions. Here's Feynman himself demolishing a related idea — the idea that scientific knowledge diminishes the perception of beauty:

You can see a beautiful thing and know some of the science behind it. You can grieve for your wife and figure out a non-magical explanation for why a clock stopped.

Nguyen continues:

Some might find this application of scientific method off-putting. But maybe it was just an unavoidable feature of one of our most interesting and brilliant modern minds.

Bad enough that Nguyen plays into the very stereotype he later tries to counter — that being scientific is an emotionally crippling "unavoidable feature". Even worse is the blog post that Nguyen links to, entitled "A Deathbed Story I Would Never Tell", in which Robert Krulwich judges Feynman's thought processes to be so unseemly he wouldn't be caught dead admitting them himself:

What [Feynman] did was, he remembered that the clock had been fragile. He had been asked to fuss with it; he'd fixed it several times. In his memoirs (that is, in his version of this story), he says the nurse must have picked up the clock to determine the time of death, unsettled the workings inside, and the clock stopped. No miracle. Just an ordinary, accidental jostle. Here he is, describing a moment of enormous significance, and he won't allow a Signifier.

I couldn't do that. I would want to, almost need to, imagine a higher audience for a moment like that.

I have a real problem with the suggestion that it's pathological not to invent a magical Signifier, with a capital S, when a moment's thought comes up with a non-miraculous explanation that makes more sense. Meanwhile, the compulsive need to "imagine a higher audience" somehow indicates a more normal person?

Don't get me wrong. I understand the impulse to "imagine", and I can see how it's natural for some people, and a good impulse for, say, a fiction writer. I like to imagine things myself from time to time. What I don't get is assuming that that impulse maps to a higher reality.

Getting back to Nguyen — I do appreciate what he's getting at, and I recommend reading his entire post. He is absolutely right that if you think Feynman was "asocial" and "cold-hearted", you should read Surely You're Joking and What Do You Care to find out how wrong you are. Hell, you should read those books anyway because they're fascinating and funny. I just think Nguyen defeats his own purpose somewhat.