Archive for the 'Mac' Category

Over the past few days, I spent more time than should have been necessary trying to drag songs from iTunes to my application’s dock icon. There is already code out there to help folks handle a drag from iTunes to a custom NSView, but nothing has ever been said about handling a drag from iTunes to your application’s dock icon.

One might think that because you can drag a song out of iTunes into the Finder, and have the file copied there, that you can simply publish support for the public.audio UTI and everything will work fine. Of course, life is not so simple.

A drag out of iTunes puts a few different flavours of data onto the pasteboard—none of which appear to be natively accepted by the dock. The most intriguing of these data items is the one with the ‘itun’ OSType. It is an XML property list that can be stuffed into an NSDictionary and then read from—this is how folks currently access the song’s location in their drag handlers (see the code link above).

Now, in order to support dragging a song from iTunes to your application’s dock icon, life gets somewhat more complicated…

First of all, to handle a pasteboard drag to your application, you must expose a service in your application’s Info.plist. Check out Will Larson’s blog post about handling text drags for more information about how to do this. I started from this point.

One might make the immediate conclusion that you can simply add itun or CorePasteboardFlavorType 0x6974756E to your list of NSSendTypes in your service definition. I did, and I was wrong—neither of these two things will cause your dock icon to accept the drag.

So, after a lengthy discussion with some other developers, I determined a bittersweet workaround. In order for this to work properly, I need you to promise me that you will do exactly as I prescribe in order to accept iTunes dock drags. So, pay close attention.

Because NSSendTypes accepts a list of NSPboardTypes or UTIs, and not OSTypes, we will have to wrap the OSType in a UTI. Unfortunately, we can’t all go around wrapping itun in different UTIs, because this will not work. The first UTI to claim itun will win out over the others, and only one application will accept these dragged songs from iTunes.

So, the ideal situation would be to wait for Apple to expose a UTI from the iTunes Info.plist, but then we would all die holding our breath. Instead, I’m asking you to define this small chunk of the Info.plist for your application.


<key>UTImportedTypeDeclarations</key>
<array>
    <dict>
        <key>UTTypeConformsTo</key>
        <array>
            <string>public.data</string>
        </array>
        <key>UTTypeIdentifier</key>
        <string>org.liscio.itun</string>
        <key>UTTypeTagSpecification</key>
        <dict>
            <key>com.apple.ostype</key>
            <string>itun</string>
        </dict>
    </dict>
</array>

Yep, I’ve gone and named it after myself—org.liscio.itun. That way, you all know where it came from. I can’t go around writing into the public.* domain, or the com.apple.* domain, so I didn’t. Using org.* instead seemed more community-oriented. :)

After you’ve imported this type, add org.liscio.itun to your list of NSSendTypes, and you’re done. Your application should now accept song drops from iTunes. (See below for some troubleshooting tips.)

Note that you’re importing this type definition in your plist, and not exporting it. In fact, all my apps will be importing it as well. Nobody should really own it, as it doesn’t belong to any of us. If Apple ever does decide to add a UTI to wrap the ‘itun’ type, then we’ll all have to change our imported type definition accordingly. I’m OK with that, and it’s really a simple thing to fix…

I hope this helps you folks give your users a better experience in your apps, and I certainly don’t mind a “digital high-five” in your About box if it’s helped you as well. You can even drop me a line to let me know that you’re going to use it. This also serves the purpose in my potentially letting you know if Apple does actually add this UTI, and it’s time to remove my UTI from your plist. ;)

Troubleshooting

I don’t expect this to happen to most of you if you get it right from the get-go, but I figured I might as well add this just in case…

The above change to your Info.plist may not take effect right away. You might have to kick the services system using NSUpdateDynamicServices() (via Ruby or Python is best), quit iTunes, or use some magic incantation of lsregister at the terminal. Sometimes you might even have to reboot and try again. This is a part of life when you’re messing around with UTIs and services during development, unfortunately.

If you’re still having trouble, first try to make sure you can register a simple service using the NSStringPboardType, and that you get called in your app delegate first. Don’t even think of asking me for help until you’ve verified this… ;)

Update: 2009/02/24

I filed a radar, rdar://6616686 for this issue, so it’s tracked appropriately by Apple. I also added it to OpenRadar for all to see: http://openrdar.com/6616686

During WWDC, I put an order in for a 17″ MacBook Pro with a glossy, high-density 1920×1200 display. I’ve had it for just under a month, and so far it’s better than any other machine I’ve used.

I had some issues with my 15″ that I don’t have at all with this machine. First off, the 15″ MacBook Pro had an annoying high-pitched whine when I first got it (it mostly went away after an overly slow repair process). It wasn’t much different from the similar noise made by my 15″ PowerBook G4, but the PowerBook didn’t leak the noise onto the built-in audio channels. There was also the audible inequality between the left & right speakers, which I spoke about earlier. I was also bummed that my 15″ MBP didn’t come with a dual-layer burner, like the last generation PowerBook G4 did.

The 17″ MacBook Pro has no whine to speak of, no electronic interference noise on the audio lines, and the speakers sound great for a portable. I can actually play music on the speakers at a reasonable level and hear a bit of low-end sound that just wasn’t there on my 15″. Oh, and the superdrive burns dual-layer discs…

Of course, there are some more positives that triggered the purchase. 64-bit capabilities of the Core 2 Duo CPU, more L2 cache, 4GB RAM, better GPU, etc. I didn’t get a new laptop just to get over the small issues I had with my 15″ system — I just found that the 17″ MacBook Pro had a critical mass of improvements to trigger the upgrade.

Of course, there are some obvious disadvantages to owning a 17″ portable. It’s heavier, has less battery life, probably won’t be easy to crack open in a plane, … I think all those things are a small price to pay for 77.8% more pixels alone, let alone the other benefits I’ve listed above.

If I could suggest improving anything, it’d probably be the addition of the LED backlight for increased battery life, and maybe a bigger battery (it’s not like they don’t have the space, and what’s an extra few ounces…). Also, I’m not overly impressed with the stock Fujitsu 160GB 5400RPM HDD — it’s slower than the 80GB 5400RPM Seagate I installed in my iBook G4 a few years ago. I’m guessing it was chosen for battery life over performance.

As usual, I’m enjoying the spark of productivity that seems to come whenever I get a new system. This time, though, I think the motivation boost is also fueled by WWDC, and also the fantastic additions in Leopard that are helping me run like a well-oiled robo-coder.

My prodigal MBP is back in my hands, in fully working order for the time being.

It’ll be a while still until I get fully on my feet again, but at least I can begin the long process of restoring all my stuff. Hopefully nothing else pops up while I try and settle back into the regular grind.

When my machine went in for the logic board replacement, I also had a problem with inverter whine, which wouldn’t be addressed until after the logic board swap. I haven’t been able to notice the whine again yet, but it’s still too early to say for sure. Hopefully it’s gone so that I can stop worrying about this machine. I guess I’ll have to get AppleCare for this system after all.

Just when I thought things were looking up…

I plugged in my USB thumb drive today to format it, and upon ejecting the volume my machine had a kernel panic. Seeing how I cannot power on my machine until I receive a new top case, I’m effectively dead in the water for getting any real work done this weekend. I hope Apple chose a really bloody fast shipping option to get my part in, because I’m really sick of waiting to return to normal.

Since I bought my MacBook Pro just a few minutes after The Keynote in January, the experience has been quite a roller-coaster.

Prologue

It all started with the “Ships February” drama, where Apple pushed the shipping date to the absolute maximum. When waiting for new hardware, especially after paying a handsome sum for it in advance, this is the most gut-wrenching time. Once you’ve made up your mind to buy something, waiting to receive it is always the worst.

Upon receiving my MacBook Pro, I was elated to see the great improvements in the speed of Mac OS X, and how much faster I could compile FuzzMeasure Pro. The performance improvements were great, but there were other little niggles that started to pick at me.

Can you hear that?

The most irritating thing was the whine. Oh how my machine whined! I wanted the whine to go away more than anything, and went through all kinds of software tricks trying to make it disappear. One day I decided to just live with it, and go on enjoying the speed — life’s too short to complain, right? I mean, I’m essentially deaf to high frequencies in my left ear, so it’s only 50% annoying, I suppose.

After a few months, Apple owned up to the whining issue. However, I was right in the middle of trying to win an Apple Design Award, and couldn’t afford to lose my machine. The whine was blocked out completely by sheer will, and I got through a very crucial period of my part-time life unscathed. After the win, and the price drop, FuzzMeasure Pro heated up again and I still couldn’t part ways with my machine — not even temporarily.

Time for repair

Fast-forward to six weeks ago. Andrew showed up, and gave me a nice distraction from my part-time work — a much needed vacation. This would be a perfect time to execute a repair. Pick up the phone, call Apple, and start the shipping/repair process — or so I thought.

My first call to Apple regarding the whine was quite frustrating. I waited about 20 minutes on hold with AppleCare, only to be told that I don’t have AppleCare and can’t speak to a representative. The machine was still well within it’s year-long warranty, and this issue was a known one. Luckily I managed to convince the representative on the phone to look up a KB article by number. She acknowledged that I needed to get my machine repaired, and all I had to do was—

Wait — You’re in Canada?

Supposedly us folks in Canada aren’t able to send our machines in via courier, have them fixed behind closed doors, and shipped back. Us simple folks can only get our repairs taken care of by Apple authorized service providers. Now I have to work to get my repair — this should be a piece of cake.

The closest store that sells Apple hardware to the general public wanted to take my machine away from me for a few days to diagnose the problem, then order parts, wait for parts, install parts, diagnose that the problem was fixed, then return the machine to me. When asked if I could make an appointment and have the problem diagnosed, then walk away with the machine until the logic board arrived, I was told that this was not possible. I had to wait at least a few days until the diagnosis could be made. Forget that — I still have a business to run, emails to answer, and bugs to fix.

Catching a break

A coworker had his MacBook Pro repaired for the whining issue at a local University’s IT department’s support desk — not something that I immediately would have attempted to try. They were authorized to do Apple warranty service for anyone off the street, and they were a short walk from work. I also managed to score a direct-line to the tech who would do the repair.

After a pleasant phone conversation, we agreed that I would take the machine over and leave it in the queue for diagnosis, which happened in time for me to get my machine the next morning. After the diagnosis, I was told that I had the most obvious, irritating whine that she had ever experienced, and the logic board was on its way. At the time, I had a new 7200RPM drive that I was planning to get installed into the machine, and she said that she’d be glad to swap the drive for me since she’d have the machine open anyway.

A few days later, I brought my machine back to accept its new mainboard, and my new 7200RPM drive. I was excited to get my quieter, cooler, faster system, and with a super-smooth process! I lucked out, right? A few hours later, the phone rang.

Good/bad news! Which do you want first?

The following conversation happened early in the week of October 2 — paraphrased, of course.

Technician: “During the logic board reinstall, the top case was found to have a defective connector, which broke off during reassembly.”

Me: “That’s actually not so bad! My top case was starting to grow a serious problem with pitting, and a new top case will make me quite happy!”

Technician: “Well, according to my system, there are no top cases in stock right now, but they should ship on October 9th.”

Me: “OK, I can live with that. Can I still use the machine?”

Technician: “Yes, but you can’t use the power button, and the keyboard/trackpad are both not functioning.”

Me: “Uhm…”

Technician: “I can turn the machine on while the case is open, but after it’s put together, you can only ever put the machine to sleep or restart it.”

Me: “I guess that’s okay. It’ll only be a few days until I get the top case anyway.”

1 Week Later

I called the technician to see if the top case arrived, and the ship date had changed to October 16th. Wow — that sucks, but I guess it’s still manageable.

2 Weeks Later

Another phonecall, and still no top case. However, the ship date for the top case still shows as October 16th!

3 Weeks Later

I called the technician again, looking for an update. The ship date is still not updated, and the part still shows that it’s out of stock.

Present Day

I still have no top case. My laptop is now effectively a desktop machine which must be treated with extreme care. I cannot mess around with anything that could cause a kernel panic or other lock-up that requires me to hard-power-off the machine. Sadly, working with audio hardware, it could happen at any time.

However, most importantly, I cannot take the machine with me away from the desk. I bought a laptop for a very good reason — I can’t get all my work done while fixed to a desk. If I worked solely at my desk, I would have gladly saved $1000 and bought an iMac.

For nearly a month, I had access to only my email and web browsing, with a touch of Xcode for emergencies. I have a FuzzMeasure Pro release that really needs to go out, and a machine that needs some reinstallation and reconfiguration for the new drive in order to make the release happen.

With Andrew in the house, the problem is further exacerbated because I cannot work on my couch, or in our bedroom, which is where we spend a lot of our time now between feedings and his “awake time”. I can’t spend my only time on my computer away from my family — I need my laptop back, and fast.

Help me, Apple!

I called AppleCare to see if I could get some further insight into the status of my part order. The technician suggested this route, because another one of her customers went this route and had some success in “unsticking” a stuck part order.

Boy was that ever a waste of time. I spent a half an hour waiting on the phone, and the AppleCare agent kept putting me on hold trying to figure out if he could help me. The end result was that they couldn’t possibly help me.

Through a friend, I managed to get the contact information for a Customer Care specialist. Unfortunately, after 3 days, I still haven’t made any direct contact (only voicemail). Supposedly this person just returned from vacation, which means he has other folks to catch up with first. So, it appears that no matter what happens, I’m stuck waiting in limbo.

Aside from the fact that I’m stuck in limbo, it’s taking an extraordinary amount of effort on my part to just get to a state of normalcy with this system. I’ve been patient with the quality issues because I was getting work done at the time, but now I’m past my boiling point — I need this sorted out ASAP.

I don’t suppose any of you, my gentle readers, have any suggestions, or perhaps the power to help? Use the comments, or feel free to email me at chris@supermegaultragroovy.com if you have any magical contact info to share.

Update (Oct 27, 2006): My top-case has shipped! I got a call back from my customer care specialist at Apple last night, and when given the information about my repair, he said he would make things happen. This morning, I got a call from my technician saying that the status changed to shipped yesterday, at some point last night (because she checked the status again before getting off work).

In the magical best case scenario, I could have the repair completed today — but that’d require Apple sending out the part with next-day shipping to Canada. What’s more likely, though, is that I’ll have to wait until Tuesday to get this sorted out. It sure is better than nothing, though!