San Francisco

I haven’t had a chance to do much blogging since I got to San Francisco, but I took lots of pictures yesterday. You can see the full gallery here.

Here’s a D-movie I took of the cable car turnaround at Powell & Market Streets.

I spent today with a realtor looking at homes & condos in the east bay. I saw one that I really liked in the San Leandro / Oakland area. I’ll be meeting her again Wednesday to look at homes in the San Mateo area.

Forgetting Keychains

Daniel Jaikut asked why the default keychain in OS X keeps getting changed, which I’ve also noticed, as have a few other people. It seems to be related to XCode and usually manifests itself as a code signing error. If you look at the provisional profiles tab in XCode’s organizer window, you’ll see a warning about a missing certificate.

I found a very simple manual fix for it. Add the following script to XCode’s script menu:


#!/bin/sh
/usr/bin/osascript - < <***
tell application "Keychain Scripting"
	set current keychain to keychain named "mike.keychain"
end tell
***

If XCode complains about a missing certificate, run that script from the menu and you’ll be OK.

I Can Has Video

As you’ve probably noticed, movies rarely work in I Can Has Cheezburger app (as a work-around, you can open the web page and click the video to play it).

The reason it doesn’t work is the movie URL returned in the feed, which is something like http://www.youtube.com/v/cxLG2wtE7TM won’t work when passed directly to a UIWebView or sent to youtube to handle. If you look at the ICHC web page containing the video, you’ll see an embed tag containing that movie URL, which a webview is able to handle correctly.

I came up with a very simple way to make videos work reliably: I create a HTML string with an EMBED tag containing the movie URL. Instead of opening the movie URL directly using UIWebView loadRequest:, I open the HTML document I built with loadHTMLString:. You’ll now have a clickable movie thumbnail, which will open in the standard YouTube player without exiting the application.

Rewriting code without fear

Over the last few days, I’ve been rewriting some major pieces of ICanHasCheezburger.app to simplify and clean up the way I handle movies. Currently I use a single image view, which is set to a ‘play’ image for movies, which then open in the browser when clicked. I’m changing it to swap between the image view for displaying images and a web view in which I open movies.

In addition, I’ve cleaned up and simplified the way I deal with the RSS feeds I obtain the images from. Previously, I had a single FeedController class, which stored the entries obtained from a CXMLDocument as an array of CXMLNodes. To display an image, open the web page, or play a movie, I had to query the FeedController for an element of the current item.

To clean it up, my FeedController now uses an array of FeedItem objects, with properties such as permalink, image URL, movie URL, and title. I now pass a FeedItem to my root view, which uses it to decide whether to display an image or movie without having to go back and query the FeedController.

I found it to be a lot easier & cleaner to use NSXMLParser, so I can create a FeedItem for each RSS item directly rather than have to manipulate the CXMLDocument, extract each CXMLNode, and create a FeedItem for it.

Until now I’ve never used XCode’s Snapshot feature. Since I use Subversion, I figured I could simply check out an earlier revision. Before I started rewriting all of that code, I saved a snapshot. It shows exactly what has changed since the snapshot and makes it very easy to revert if something goes wrong. It’s very similar to checking in to Subversion or reverting to an earlier revision, but it’s a lot faster and more convenient. I find it very liberating to be able to make a major change like this and not have to worry about messing up, since I can easily go back to the way it was.

Snapshots